【发布时间】:2016-05-27 09:24:49
【问题描述】:
我在所有链接中添加一个“:after”元素(模拟一个“border-bottom”)等“:hover”我可以为这个伪元素设置动画(“height: 100%”)。这很好用,但是当使用换行符拆分链接时,伪元素在换行符后被破坏。
a {
color: red;
position: relative;
text-decoration: none;
&:after {
transition: height .1s;
background-color: red;
bottom: -3px;
content: '';
display: inline;
height: 3px;
left: 0;
right: 0;
position: absolute;
width: 100%;
z-index: -1;
}
&:hover:after {
height: calc(100% + 4px);
}
&:hover {
color: white;
}
}
这是一支笔:
http://codepen.io/herrfischer/pen/YWKmQJ
知道我做错了什么吗?
【问题讨论】:
标签: css sass pseudo-element