我正在使用我找到的一些风格这个网站 http://callmenick.com/post/simple-css3-transitions-transforms-animations-compilation创建有效的下划线幻灯片。请参见jsfiddle http://jsfiddle.net/juhL2256/例如。
正如您所看到的,下划线是从左到右的。我将如何在文本顶部制作另一行,从右向左过渡?我可以简单地调整当前的代码片段,还是必须使用完全不同的方法?
.cmn-t-underline {
position: relative;
color: #ff3296;
}
.cmn-t-underline:after {
display: block;
position: absolute;
left: 0;
bottom: -10px;
width: 0;
height: 10px;
background-color: #2E9AFE;
content: "";
-webkit-transition: all 0.3s;
-moz-transition: all 0.3s;
-o-transition: all 0.3s;
transition: all 0.3s;
height:2px;
}
.cmn-t-underline:hover {
color: #98004a;
}
.cmn-t-underline:hover:after {
width: 100%;
height:2px;
}
<h1 class="cmn-t-underline">Test</h1>
试试这个,它会如你所愿
.cmn-t-underline {
position: relative;
color: #ff3296;
}
.cmn-t-underline:after {
display: block;
position: absolute;
left: 0;
bottom: -10px;
width: 0;
height: 10px;
background-color: #2E9AFE;
content: "";
-webkit-transition: all 0.3s;
-moz-transition: all 0.3s;
-o-transition: all 0.3s;
transition: all 0.3s;
height:2px;
}
.cmn-t-underline:hover {
color: #98004a;
}
.cmn-t-underline:hover:after {
width: 100%;
height:2px;
}
.cmn-t-underline:hover:before {
width: 100%;
height:2px;
}
.cmn-t-underline:before {
display: block;
position: absolute;
right: 0;
top: 0px;
width: 0;
height: 10px;
background-color: #2E9AFE;
content: "";
-webkit-transition: all 0.3s;
-moz-transition: all 0.3s;
-o-transition: all 0.3s;
transition: all 0.3s;
height:2px;
}
<h1 class="cmn-t-underline">Test</h1>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)