【发布时间】:2015-02-16 11:52:07
【问题描述】:
我使用inline-block 将多个锚点安排为选项卡条中的选项卡,该选项卡条在溢出时水平滚动,而不是将选项卡包装成多行。
这在 Windows 上的 Chrome 和 FF 以及 iPad 上的 Chrome/Safari 上运行良好,但在 IE 9 上非常时髦。
IE 9 上的问题是,当我将锚标记悬停时,更改元素颜色和背景颜色的伪选择器会导致父 div 增加它的高度。我认为这是一个 IE 9 错误,但我无法验证。
我发现了一个 hack 修复,它涉及使用 overflow:hidden 和特定的 height 将父元素包装在块元素中,但我想尽可能避免使用特定的高度。
问题:
- 什么是不涉及 IE hack 或特定宽度的通用修复?
- 为什么只有在使用
:hover伪类时才会出现这种情况? - 有没有更好的做法来按我想要的方式来处理标签(如果超出宽度则滚动;不要换行)?
问题小提琴:http://jsfiddle.net/oyzpxr6m
黑客修复小提琴:http://jsfiddle.net/oyzpxr6m/1/
示例代码:
.tabs {
display: block;
white-space: nowrap;
background-color: blue;
overflow: auto;
}
.tabs a {
display: inline-block;
border: 1px solid #ccc;
color: #fff;
}
.tabs a:hover {
background-color: red;
}
<div class='tabs'>
<a href='tab'>tab name goes here</a>
<a href='tab'>tab name goes here</a>
<a href='tab'>tab name goes here</a>
<a href='tab'>tab name goes here</a>
<a href='tab'>tab name goes here</a>
<a href='tab'>tab name goes here</a>
<a href='tab'>tab name goes here</a>
<a href='tab'>tab name goes here</a>
<a href='tab'>tab name goes here</a>
<a href='tab'>tab name goes here</a>
<a href='tab'>tab name goes here</a>
<a href='tab'>tab name goes here</a>
<a href='tab'>tab name goes here</a>
<a href='tab'>tab name goes here</a>
<a href='tab'>tab name goes here</a>
<a href='tab'>tab name goes here</a>
<a href='tab'>tab name goes here</a>
<a href='tab'>tab name goes here</a>
<a href='tab'>tab name goes here</a>
<a href='tab'>tab name goes here</a>
<a href='tab'>tab name goes here</a>
<a href='tab'>tab name goes here</a>
<a href='tab'>tab name goes here</a>
<a href='tab'>tab name goes here</a>
<a href='tab'>tab name goes here</a>
<a href='tab'>tab name goes here</a>
<a href='tab'>tab name goes here</a>
<a href='tab'>tab name goes here</a>
</div>
<h3>some content goes here</h3>
【问题讨论】:
-
嗯,刚刚意识到我可以改用
display:inline,呃,但仍然想知道为什么这个“错误”只出现在 IE 中 -
@nothingisnecessary 很棒的错误!我是 IE 团队的工程师,很乐意为您调查。
标签: html css internet-explorer internet-explorer-9