【问题标题】:Tabbing between links causes issues with pseudo-elements in Chrome在链接之间切换会导致 Chrome 中的伪元素出现问题
【发布时间】:2014-12-12 11:03:03
【问题描述】:
在 Chrome 中,单击结果窗格并点击选项卡以关注此处的第一个链接:
http://jsfiddle.net/2q6c7c36/2/
注意 .box 的内容是如何“跳”到其边界之外的?这似乎是由我正在使用的 clearfix 类引起的。这是 Chrome 中的错误还是我做错了什么?我在对图标字体使用伪元素时也注意到了这一点。
谢谢。
.clearfix:after{
content: ".";
visibility: hidden;
display: block;
height: 0;
clear: both;
}
【问题讨论】:
标签:
html
css
google-chrome
pseudo-element
clearfix
【解决方案1】:
演示 - http://jsfiddle.net/victor_007/2q6c7c36/3/
将content:"." 设置为content:""
.box {
border: 2px solid black;
border-radius: 10px;
position: absolute;
float: left;
width: 318px;
overflow: hidden;
}
.clearfix:after {
content: "";
visibility: hidden;
display: block;
height: 0;
clear: both;
}
a {
display: inline-block;
background-color: #555;
color: white;
text-decoration: none;
font-family: helvetica;
padding: 3px;
}
<div class="box clearfix">
<a href="#" class="button">Button</a>
<a href="#" class="button">Button</a>
<a href="#" class="button">Button</a>
</div>