use the css transform scale property to scale an element on hover - zilongxuan001/LearnFreecode GitHub Wiki
transform
属性有很多的功能可以让你的元素改变比例(scale),移动(move),旋转(rotate),扭曲(skew)等等。
当你使用伪类(pesedo-classes)比如用于显示元素一定状态的:hover
,transform
属性很容易为你的元素增加相互作用。
这是一个例子,当一个用户的鼠标停在段落上时,段落被变成原来的2.1倍。
p:hover {
transform: scale(2.1);
}
为div
的hover
状态增加一条CSS规则,使用transform
属性。当用户把鼠标放在div
元素上时,div
会变成原来的1.1倍。
<style>
div {
width: 70%;
height: 100px;
margin: 50px auto;
background: linear-gradient(
53deg,
#ccfffc,
#ffcccf
);
}
div:hover {
transform: scale(1.1);
}
</style>
<div></div>
2018-10-30 15:13:05