作者热门文章
- objective-c - iOS 5 : Can you override UIAppearance customisations in specific classes?
- iphone - 如何将 CGFontRef 转换为 UIFont?
- ios - 以编程方式关闭标记的信息窗口 google maps iOS
- ios - Xcode 5 - 尝试验证存档时出现 "No application records were found"
我想在我的网站上添加一些过渡效果。我已经知道当有人在输入字段中时(所以:焦点)边框会随着过渡改变颜色。我希望这种过渡发生在从中间到左边和右边。
因此动画是向两侧扩展的边界。 CSS 有可能吗?如果我必须使用 Jquery 或 Javascript,那没问题。
提前致谢,伊恩
最佳答案
您可以使用 CSS 进行边框过渡。希望这可以帮助。 CODEPEN example
HTML :
body {
padding: 50px;
}
a, a:hover {
color: #000;
text-decoration: none;
}
li {
display: inline-block;
position: relative;
padding-bottom: 3px;
margin-right: 10px;
}
li:last-child {
margin-right: 0;
}
li:after {
content: '';
display: block;
margin: auto;
height: 3px;
width: 0px;
background: transparent;
transition: width .5s ease, background-color .5s ease;
}
li:hover:after {
width: 100%;
background: blue;
}
<ul>
<li><a href="#">HOME</a></li>
<li><a href="#">PAGE</a></li>
<li><a href="#">ABOUT US</a></li>
<li><a href="#">CONTACT US</a></li>
</ul>
关于CSS: bottom-border-transition - 从中间展开,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26726436/
这个问题在这里已经有了答案: Is a moved-from vector always empty? (4 个答案) 关闭 4 年前。 从 std::vector move 数据后,它的容量是否必
我是一名优秀的程序员,十分优秀!