【发布时间】:2018-02-16 06:52:16
【问题描述】:
我使用了一个带有背景效果的按钮。但是,我不明白背景位置是如何工作的。
背景位置设置在右侧,然后当我将鼠标悬停在按钮上时,背景会向左移动。但是,我不明白为什么“蓝色”似乎是从左到右,就像背景向右移动一样。
背景不应该向左移动吗?
button {
color: white;
background: linear-gradient(to left, red 50%, blue 50%);
background-size: 200%;
background-position: right bottom;
border: none;
border-radius: unset;
width: 85px;
height: 35px;
transition: 2s ease;
cursor: pointer;
}
button:hover {
background-position: left bottom;
}
<button>Button</button>
【问题讨论】:
-
你可以从左到右和从右到左反转来镜像它。
-
它会,如果
background-size会小于100%,如果尺寸大于按钮的实际尺寸,它将在反向版本中工作 -
它在反向版本中工作的原因是什么?
标签: html css linear-gradients background-position