【问题标题】:The html table width just out of control in Firefox and IE [closed]Firefox 和 IE 中的 html 表格宽度刚刚失控 [关闭]
【发布时间】:2017-05-13 21:48:22
【问题描述】:

我应该用 div 构建它,但我必须为我的客户(虚拟用户)使用表。 所以我用 CSS 构建了这个在 Chrome 中完美运行的 html 表。

我已经阅读了一些相关主题,但没有掌握关键技巧!希望有人告诉我错了。

这是我的 CSS,我有 jsfiddle demo here(仅适用于 Chrome) 请先在 Chrome 中查看 jsfiddle 演示,然后尝试 Firefox,你就会明白我的意思了。

#content_container {
    width:960px;
}
#content_container .fullcontainer > table {
    border-bottom: 4px solid #222;
}
#content_container .fullcontainer {
width:inherit !important;
margin: 0 auto !important;
padding: inherit !important;
}
#content_container table.eurostyle {
    margin: 25px auto !important;
    border-collapse: collapse !important;
    font-family: Gotham, "Helvetica Neue", Helvetica, Arial, sans-serif !important;
    text-shadow: 1px 1px 1px #eee;
}
table td img.alignleft {
margin: 0;
}
body h2 {
font-family: Gotham, "Helvetica Neue", Helvetica, Arial, sans-serif !important;
font-weight: bold;
}
.eachtop {
    border-top: 4px solid #222;
    border-color: #000;
}
.eachaside {
    border-top: 1px solid #222;
    border-top: 1px solid #ccc;
    font-size: 12px;
}
table td {

}
table h2 {
    margin: 2px 0;
    line-height: 1.1em;
    font-size: 22px;
}
.eachtop > td:first-child {
/*height: 40px;*/
padding: 3px 0;
}
.tdfit {
    padding: 0 0 0 1px;
    line-height: 0;
}
.ctable {
    margin: 0 0 0 0px;
}
.ctable td img, .tdfit img {
    max-width: 100%;
    height: auto;
}
.ctable td {
    padding: 1px;
    border: 1px solid #000000;
    border-top: none;
    border-bottom: none;
    line-height: 0.9;
}
.ctable td img {

        }

【问题讨论】:

  • 问题不应该要求读者做额外的工作来解决问题。你能告诉我们这个问题,这样我们就不必为你调试了吗?

标签: html css internet-explorer firefox css-tables


【解决方案1】:

table-layout: fixed 添加到您的表中,您的问题将得到解决。

来自 CSS 技巧:

有了适当的财产/价值,事情变得更加稳固和可预测。布局基于第一行固定。设置它们的宽度,表格的其余部分如下。

这意味着,代替表格的 内容 决定宽度,表格第一行的样式现在将决定下面其余行的宽度,这使得布局更多,您猜对了,已修复!

工作示例(经过测试的 Firefox):

http://jsfiddle.net/gt5t01ov/2/

【讨论】:

  • 嗨,我没有看到你的小提琴作品。它仍然在 Firefox 中显示错误的宽度。
  • @bard 只需将table-layout:fixed 添加到所有表...它可以工作
  • 谢谢,现在我得到了关键点!
  • 成功了!谢谢:)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-07-16
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-09-04
相关资源
最近更新 更多