12
如何在CSS3中创建下划线动画从hover
从左到右?下划线CSS3转换
如何在CSS3中创建下划线动画从hover
从左到右?下划线CSS3转换
这是一个非常棘手的问题。
唯一的解决办法我能想出是对:hover
过渡border-bottom
或我其实应该说,我在过渡border-bottom
,width
和margin-right
使border-bottom
出现,并在同一时间保持,在这种情况下,链接对齐。
很难解释,所以我做了一个快速的例子,它不完美,看起来有点乱,但至少它表明了我的意思。 :-)
HTML
<a href="#">Link</a><a href="#">Link</a>
CSS
a {
text-decoration: none;
display: inline-block;
border-bottom: 1px solid blue;
margin-right: 39px;
width: 0px;
-webkit-transition: 0.5s ease;
transition: 0.5s ease;
}
a:hover {
-webkit-transition: 0.5s ease;
transition: 0.5s ease;
border-bottom: 1px solid blue;
width: 30px;
margin-right: 9px;
}
宽度设置为0,从而有实际的内容流出来的链接,可能对其他的副作用的布局。我建议使用生成的元素(:after),将其绝对位于链接的底部,而不是动画改变该伪元素的宽度。 – CBroe 2013-03-19 10:53:30
对我有用的人很好,非常感谢! – ziltoid 2013-03-19 11:27:15