- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我在下面有 2 个示例,它们显示 4 个链接并将鼠标悬停在它们上面显示边框底部,效果很轻松。
在示例 1 中,border-bottom 从上到下显示。我已经尝试使用示例 2 中的 padding 属性,它在浏览器中不一致并且不能正常工作。
示例1:转换默认功能(从上到下转换)
<!DOCTYPE html><html class=''>
<head>
<style class="cp-pen-styles">
body {
padding: 50px;
}
a, a:hover {
text-decoration: none;
}
li {
position: relative;
padding-bottom: 3px;
margin-right: 10px;
display: inline;
}
li a {
border-bottom: 0em solid transperant;
color: #777;
}
li:focus > a,
li:hover > a,
li:active > a {
border-bottom: 0.313em solid #206E9F;
transition: border-bottom .2s ease-in-out;
-webkit-transition: border-bottom .2s ease-in-out;
-moz-transition: border-bottom .2s ease-in-out;
-ms-transition: border-bottom .2s ease-in-out;
}
|
</style>
</head>
<body>
<ul>
<li><a href="#home">HOME</a></li>
<li><a href="#page">PAGE</a></li>
<li><a href="#about">ABOUT US</a></li>
<li><a href="#contact-me">CONTACT US</a></li>
</ul>
</body>
</html>
示例 2:从下到上的过渡(使用填充 - 与 IE 浏览器的兼容性问题)
<!DOCTYPE html><html class=''>
<head>
<style class="cp-pen-styles">
body {
padding: 50px;
}
a, a:hover {
text-decoration: none;
}
li {
position: relative;
padding-bottom: 3px;
margin-right: 10px;
display: inline;
}
li a {
color: #777;
padding-bottom:0.4em;
border-bottom: 0em solid transperant;
}
li:focus > a,
li:hover > a,
li:active > a {
padding-bottom:0em;
border-bottom: 0.313em solid #206E9F;
transition: all .2s ease-in;
-webkit-transition: all .2s ease-in;
-moz-transition: all .2s ease-in;
-ms-transition: all .2s ease-in;
}
</style></head><body>
<ul>
<li><a href="#home">HOME</a></li>
<li><a href="#page">PAGE</a></li>
<li><a href="#about">ABOUT US</a></li>
<li><a href="#contact-me">CONTACT US</a></li>
</ul>
</body></html>
如何使 CSS3 过渡适用于从下到上开始的 border-bottom 属性。
最佳答案
您可以使用 :after 模拟您想要的结果或 :before伪元素。这样您就可以更好地控制所需的效果(例如添加各种变换)。
body {
padding: 50px;
}
a {
text-decoration: none;
}
li {
display: inline;
margin-right: 10px;
}
li a {
border-bottom: 0 solid transparent;
color: #777;
display: inline-block;
padding-bottom: 3px;
position: relative;
}
li a > .fancy-line {
background-color: transparent;
content: "";
display: block;
height: 0;
position: absolute;
bottom: 0;
left: 0;
right: 0;
-o-transition: background-color 0.2s ease-in-out, height 0.2s ease-in-out;
-ms-transition: background-color 0.2s ease-in-out, height 0.2s ease-in-out;
-moz-transition: background-color 0.2s ease-in-out, height 0.2s ease-in-out;
-webkit-transition: background-color 0.2s ease-in-out, height 0.2s ease-in-out;
transition: background-color 0.2s ease-in-out, height 0.2s ease-in-out;
}
li a:hover > .fancy-line {
background-color: #206E9F;
height: 3px;
}
<ul>
<li><a href="#home">HOME <span class="fancy-line"></span></a></li>
<li><a href="#page">PAGE <span class="fancy-line"></span></a></li>
<li><a href="#about">ABOUT US <span class="fancy-line"></span></a></li>
<li><a href="#contact-me">CONTACT US <span class="fancy-line"></span></a></li>
</ul>
关于css - 如何使 CSS3 过渡适用于从下到上开始的 border-bottom 属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35593658/
有没有办法像 super 速记样式一样在 CSS 中组合 border-top,border-right,border-left,border-bottom。 例如: border: (1px sol
这个问题在这里已经有了答案: Combining border-top,border-right,border-left,border-bottom in CSS (4 个答案) 关闭 3 年前。
所以,我是那些以始终使用最新版本的浏览器而自豪的人之一(当然 Internet Explorer 除外 - 我说的不是那个浏览器)。 我遇到了 this awesome CSS3 website详细介
border-top-color 是 #9b9c9d 而 border-bottom-color 是 #f6f9fc .渐变旨在在border-left 和border-right 上将顶部颜色过渡到
我将开始开发一个新网站,并准备处理浏览器用于计算元素宽度和高度的不同方法 (box model stuff)。不知何故,我想到了:如果我只是将 box-sizing 应用于网站中的所有元素会怎么样?
这是 fiddle :http://jsfiddle.net/3Ys2d/ CSS div{ border: solid 3px blue; border-left-color: re
这个接缝很容易,但我还没有找到任何方法来做到这一点。我有 3 个 div(但解决方案必须适用于 n 个 div),如下图所示: |分区 1 ||分区 2 ||第 3 部分 | 例如: 我想要这样的普通
由于视网膜显示器具有如此高的像素密度,因此在这些显示器上 1 像素的边框看起来非常大。正如 Brad Birdsall 所建议的,CSS box-shadow属性可用于创建“0,5 px”边框,在
我可以这样写边框的样式: border: 2px solid #DDDDDD; 或者像这样: -moz-border-bottom-colors: none; -moz-border-left-col
当在已经有 1px 边框的 div 中覆盖 border-bottom 的大小时,Firefox 和 Chrome 呈现 border-left 和 border-right 不正确: HTML C
我是CSS3新手,最近在学习border-image属性,在看W3C文档的时候: http://dev.w3.org/csswg/css-backgrounds/#border-image-width
我正在尝试在使用 border-radius 属性的 div 上使用 border 属性。 这是我的 CSS: #page { border: 1px solid #beb2b2; w
我只想在已经具有顶部和底部边框(1px 纯灰色)的 div 上添加一个左边框(5px 纯蓝色)。我希望 border-left 位于 border-top 和 border-bottom 之上,但浏览
我有一个使用 border-radius 的带有圆 Angular 的流体宽度 div,以及 div 一侧的大边框,颜色不同。 当浏览器窗口足够小时,所有边框都会正常运行。但是,当我放大窗口大小时,我
导致“错误”的 Css: div { width: 100px; height: 100px; background-color: transparent; box-s
Border-bottom长度小于border-right怎么办? img { border-bottom: 5px solid #02a8d8; border-right:1px s
我是一名优秀的程序员,十分优秀!