0

我正在创建一个具有单列布局的 HTML5 网页。基本上,它是一个带有单独帖子的论坛主题。

我在我的 CSS 文件中指定该列的宽度为 600 像素,并使用margin: 0 auto;. 但是,个别帖子中的某些图像大于 600 像素并溢出列。

我想扩大单个帖子以适应更大的图像。但是,我希望所有其他帖子仍然是 600 像素宽。

现在,我只是使用overflow:auto它来创建一个滚动条,但这并不理想。这是否可以让单个帖子的宽度针对较大的内容增长,而对于普通内容保持固定?这可能只使用纯CSS吗?

提前致谢!

4

2 回答 2

3

try using min-width: 600px instead of width, though it won't work in old versions of internet explorer.

于 2010-03-26T19:41:01.703 回答
0

您可以在包含您的帖子的 div 上使用 display:table。您可以使用此示例标记查看效果:

<html>
  <head>
    <style>
      .post{
        margin:0 auto;
        border:1px solid red;
        display:table;
      }
    </style>
  </head>
    <body style="width:100%;border:1px solid blue;">
      <div class="post" style="width:600px;">
        asd
      </div>
    <div class="post" style="width:900px;">
      asd
    </div>
    </body>
</html>

当然,这在 IE 8 下是行不通的。

于 2010-03-26T22:06:39.370 回答