html - IE7 宽度 :auto issue

标签 html css internet-explorer width internet-explorer-7

CSS

    #wrapper .tn{
      width:auto;
      height:20px;
      line-height:20px;
      float:left;
      padding:5px 2px 5px 5px;
      margin:0 5px 10px;
      font-weight:bold;
      background:#f0f0f0;
    }

HTML

    <div id="wrapper">
        <div class="tn">Text</div>
        <div class="tn">Text</div>
        <div class="tn">Text</div>
    </div>

以上代码在 FF,Chrome,Safari,Opera,IE9,IE8 中运行流畅。但是IE7有问题。 div 不根据文本扩展。它覆盖 wrapper div 作为宽度。我该如何解决这个问题?

最佳答案

我觉得没问题,使用 IE7 开发人员工具进行了检查,您可以尝试使用 display: inline-block; 而不是 float

#wrapper .tn{
  height:20px;
  line-height:20px;
  padding:5px 2px 5px 5px;
  margin:0 5px 10px;
  font-weight:bold;
  background:#f0f0f0;
  display: inline-block;
}

关于html - IE7 宽度 :auto issue,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14023155/

相关文章:

internet-explorer - IE8 : CSS opacity filter results font color to become the same as the background div's background color

javascript - Bootstrap 在 IE10 中仍未显示

javascript 无法与 HTML 正确链接。怎么修?

html - 删除内联跨度元素的填充

javascript - 如何使用 JQuery 将动画内容移回悬停后的正常位置

css - 选择带有 Font Awesome 图标的选项

javascript - 如何处理 IE 错误

php - 使用 codeigniter 和 mysql 回显图像数组

html - 隐藏 HTML 输入控件中的值或文本

html - 提高 KineticJS 性能的最佳方法是什么,尤其是在移动设备上?