简单说明一下,原文字有一个浅色的下划线,鼠标悬停后,会有从左到右变成深色线的动画效果。
position要设置为relative,after中要配合使用content和transition。具体详见下面代码
.ls-index-news .news-body a {
position: relative;
border-bottom: 1px solid #EFEFEF;
color: #595959;
display: block;
padding-bottom: 8px;
text-decoration: none;
}
.ls-index-news .news-body a:after {
content: '';
position: absolute;
bottom: 0;
left: 0;
width: 0%;
border-bottom: 1px solid #595959;
transition: 0.4s;
}
.ls-index-news .news-body a:hover:after {
width: 100%;
}
主要参考来自:http://www.cssportal.com/blog/css-animated-underline-links/
评论
No comments yet.