难点所在
- 这个动画效果中,下划线是从一端进入,从另外一端离开的。而且,这个 hover 动画是纯 CSS 实现的。
还原效果
- 正常而言,我们一个 hover 效果,可能就是从哪里来,回哪里去,大部分的应该是这样的:
html :
<div>hover me</div>
css:
div {
position: relative;
width: 200px;
height: 60px;
line-height: 60px;
text-align: center;
margin: 20px auto;
font-size: 32px;
color: #333;
cursor: pointer;
}
div:before {
content: "";
display: block;
height: 2px;
background-color: red;
position: absolute;
bottom: 0;
}
div::before {
left: 0;
width: 0;