我正在使用我在this website找到的某种样式来创建有效的下划线幻灯片。例如,请参阅jsfiddle 如您所见,下划线从左到右。我将如何在文本顶部创建另一行,从右到左过渡?我可以简单地调整当前的代码片段,还是必须完全使用其他方法?
.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>
&#13;
答案 0 :(得分:3)
试试这个,它可以随心所欲地工作
.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>
答案 1 :(得分:2)
http://jsfiddle.net/juhL2256/1/
从左到右更改。
.cmn-t-underline:after {
display: block;
position: absolute;
right: 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;
}