views:

148

answers:

2

I am creating an HTML5 web page with a one column layout. Basically, it is a forum thread with individual posts.

I have specified in my CSS file the column to be 600px wide and centered it in the window using margin: 0 auto;. However, some images that are in the individual posts are larger than 600px and spill out of the column.

I'd like to widen an individual post to fit the larger images. However, I want all the other posts to still be 600px wide.

Right now, I'm just using overflow:auto which will create a scroll bar, but this is less than ideal. Is this possible to have the an individual post width grow for larger content yet stay fixed for normal content? Is this possible using just pure CSS?

Thanks in advance!

+3  A: 

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

Chibu
This does not work. Thanks though! I have a bunch of div elements all with the class=post. And I want only the post with giant images to be larger than 600px. The rest of the posts should be 600px.
ChrisJF
A: 

You can use display:table on divs that contain your posts. You can see the effect with this example markup:

<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>

Of course this will not work IE under version 8.

hamdiakoguz