【发布时间】:2016-11-23 13:43:33
【问题描述】:
我试图弄清楚这一点,但我无法理解他使用了什么代码。
我想重新创建类似于他在右上角的效果的东西。动画滑动条在出现和消失时改变颜色。
我很确定来自http://bradsknutson.com/blog/css-sliding-underline/ 的代码是这个的基础。我已经设法让滑动条使用它来改变颜色,但它不是那么平滑并且颜色变化太突然。
我的尝试: http://codepen.io/Dingerzat/pen/mOmzVp
/* CSS */
.sliding-u-l-r-l {
display: inline-block;
text-decoration:none;
color: #000000;
position: relative;
padding-bottom: 3px;
}
.sliding-u-l-r-l:before {
content: '';
display: block;
position: absolute;
left: 0;
bottom: 0;
height: 3px;
width: 0;
transition: width 0s ease, background .5s ease;
}
.sliding-u-l-r-l:after {
content: '';
display: block;
position: absolute;
right: 0;
bottom: 0;
height: 3px;
width: 0;
background: blue;
transition: width .5s ease;
}
.sliding-u-l-r-l:hover:before {
width: 100%;
background: red;
transition: width .5s ease;
}
.sliding-u-l-r-l:hover:after {
width: 100%;
background: transparent;
transition: all 0s ease;
}
.
<!-- HTML -->
<a class=sliding-u-l-r-l href="http://codepen.io">A link that is and never is</a>
【问题讨论】:
-
codepen 是否会导致问题?
-
老兄,对不起。我什至没有注意到它...
-
嗯,我可能应该开始使用代码片段了,我觉得 codepen 在这里有点不受欢迎?
-
其实,我更喜欢 JSFiddle、CodePen、Plunker等……它们更容易编辑和修改。
-
你还想要多久?