【问题标题】:div doesnt expand as table expands, or div doesnt center when it expanddiv 不会随着表格的展开而展开,或者 div 不会在展开时居中
【发布时间】:2011-04-09 22:50:00
【问题描述】:

嗯,这很奇怪。

它在 IE 中有效,但在 FF 中无效。

请看:http://www.sumsy.com/temp/test11/test.html(表格初始为980px) http://www.sumsy.com/temp/test11/test2.html(表格扩大到1200px)

问题是,表格展开后,最外层的 div (#body-left) 在 FF 中不再居中。左边的空间保持不变。

我用firebug检查,看起来#body-left div宽度固定为999px,所以当表格展开时它没有展开。

我可以通过从#body-left div 中删除 999px 宽度来修复它。但如果我这样做,div 将不再居中。

我需要它居中,所以我必须为它指定一个宽度?

有什么解决办法吗?

谢谢。

【问题讨论】:

    标签: css


    【解决方案1】:
    • #body-left 中删除width 属性,并添加display: inline-block
    • body 上,添加text-align: center
    • #body-left 上,添加text-align: left

    Live Demo

    如果您关心IE7,请添加到#body-left*display: inline; zoom: 1

    【讨论】:

      猜你喜欢
      • 2018-08-21
      • 2011-05-18
      • 1970-01-01
      • 1970-01-01
      • 2018-04-23
      • 2015-12-20
      • 1970-01-01
      • 2019-03-23
      • 1970-01-01
      相关资源
      最近更新 更多