hover.css是一个CSS3的鼠标悬停效果,可应用于链接,按钮,徽标,SVG,特色图像等。
下面是一些常用的效果源码
Border Transitions
- Underline From Center
关键控制before元素的 left,right的值来进行动画,当了left,right,都为0的时候,before会继承父元素的宽度。一开始left,right都处于51%的位置也就是中间,宽度正好为0,而且居中。hover上去的时候值变为0,宽度为父元素的宽度。调货hover的值,就能实现反转效果
/* Underline From Center */
.hvr-underline-from-center {
display: inline-block;
vertical-align: middle;
transform: perspective(1px) translateZ(0);
box-shadow: 0 0 1px rgba(0, 0, 0, 0);
position: relative;
overflow: hidden;
}
.hvr-underline-from-center:before {
content: "";
position: absolute;
z-index: -1;
left: 51%;
right: 51%;
bottom: 0;
background: #2098D1;
height: 4px;
transition-property: left, right;
transition-duration: 0.3s;
transition-timing-function: ease-out;
}
.hvr-underline-from-center:hover:before, .hvr-underline-from-center:focus:before, .hvr-underline-from-center:active:before {
left: 0;
right: 0;
}
网友评论