IE 7 中的无换行问题
HTML:
<ul id="popular-tags-hidden">
<li id="tag-1"><a class="display-new-tag" href="#">Tag 1<img width="10" height="10" src="http://www.communr.com/images/add-tag.png"></a></li>
<li id="tag-2"><a class="display-new-tag" href="#">Tag 2<img width="10" height="10" src="http://www.communr.com/images/add-tag.png"></a></li>
<li id="tag-3"><a class="display-new-tag" href="#">Tag 3<img width="10" height="10" src="http://www.communr.com/images/add-tag.png"></a></li>
<li id="tag-4"><a class="display-new-tag" href="#">Tag 4<img width="10" height="10" src="http://www.communr.com/images/add-tag.png"></a></li>
<li id="tag-5"><a class="display-new-tag" href="#">Tag 5<img width="10" height="10" src="http://www.communr.com/images/add-tag.png"></a></li>
</ul>
CSS:
ul#popular-tags-hidden li {
float: left;
overflow: hidden;
margin: 3px 6px 3px 0;
}
a.delete-new-tag, a.display-new-tag {
float: left;
background: #e2f2ce;
height: 20px;
padding: 0 5px 0 5px;
margin: 0;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
white-space: nowrap;
display: inline-block;
color: #466840;
}
IE 7 结果:
所需结果:
标签在 ul 容器的右侧被切断。我尝试研究这个问题,我认为这与填充有关,但我无法弄清楚。适用于除 IE7 之外的所有浏览器。
HTML:
<ul id="popular-tags-hidden">
<li id="tag-1"><a class="display-new-tag" href="#">Tag 1<img width="10" height="10" src="http://www.communr.com/images/add-tag.png"></a></li>
<li id="tag-2"><a class="display-new-tag" href="#">Tag 2<img width="10" height="10" src="http://www.communr.com/images/add-tag.png"></a></li>
<li id="tag-3"><a class="display-new-tag" href="#">Tag 3<img width="10" height="10" src="http://www.communr.com/images/add-tag.png"></a></li>
<li id="tag-4"><a class="display-new-tag" href="#">Tag 4<img width="10" height="10" src="http://www.communr.com/images/add-tag.png"></a></li>
<li id="tag-5"><a class="display-new-tag" href="#">Tag 5<img width="10" height="10" src="http://www.communr.com/images/add-tag.png"></a></li>
</ul>
CSS:
ul#popular-tags-hidden li {
float: left;
overflow: hidden;
margin: 3px 6px 3px 0;
}
a.delete-new-tag, a.display-new-tag {
float: left;
background: #e2f2ce;
height: 20px;
padding: 0 5px 0 5px;
margin: 0;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
white-space: nowrap;
display: inline-block;
color: #466840;
}
IE 7 Result:
Desired Result:
The tags get cut off on the right side of the ul container. I have tried researching the problem and I think it has something todo with the padding, but I can't figure it out. Works in all browsers except IE7.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
解决此问题的一种方法是在 li 上从
float: left
切换为display: inline-block
。如果您只对 IE7 执行此操作,那就没那么麻烦了:
比较:
float: left
(如您所愿):http://jsfiddle.net/cqSUy/display: inline-block
仅适用于 IE7: http://jsfiddle.net/CfXq6/关于
*display: inline;缩放:1
- 内联块在 Internet Explorer 7、6 中不起作用简而言之,这就是 IE7 的
display: inline-block
的说法。One way to fix it is to switch from
float: left
todisplay: inline-block
on theli
s.It's less hassle if you do this for only IE7:
Compare:
float: left
(as you had it): http://jsfiddle.net/cqSUy/display: inline-block
for only IE7: http://jsfiddle.net/CfXq6/About
*display: inline; zoom: 1
- Inline block doesn't work in internet explorer 7, 6In short, it's how you say
display: inline-block
for IE7.