views:

104

answers:

3

I need CSS definitions for the following layout:

<div id="middle-wrapper">
  <div id="column1-wrapper">
    This has to be 100% - 250px wide
  </div>
  <div id="column2-wrapper">
    This has to be 250px wide
  </div>
  <!-- no other markup in middle-wrapper except maybe a clearing div -->
</div>
  • middle-wrapper needs to be 100% wide
  • column2-wrapper needs to be 250px wide
  • column1-wrapper should take all available space

In summary, column1-wrapper should be 100% - 250px wide and I need both of the columns to look like columns.

I've tried adding float: left to BOTH columns. However this means column1-wrapper looses its width. On pages that do not contain enough content in the left column, the right column aligns itself with the left column and ends up somewhere in the middle of the page:

----------------------------------------------------------------
| LEFT NO WIDTH COLUMN|| RIGHT 250 PX|
----------------------------------------------------------------

I've tried adding float: left to LEFT column and float: right to RIGHT column. That aligns the right column with the right edge but the left column does not stretch appropriately:

----------------------------------------------------------------
| LEFT NO WIDTH COLUMN|                          | RIGHT 250 PX|
----------------------------------------------------------------
+2  A: 

Try giving float:right to the right column and nothing at all to the left one. Don't float it, don't specify a size, just put the content you want inside it and that's it.


Oh sorry I forgot: you must put column2 inside column1


Yeah, this works:

<html>
<head>

<style>
    div#column1-wrapper {
        width: 100%;
    }

    div#column1-wrapper {
    }

    div#column2-wrapper {
        float: right;
        width: 250px;
    }
</style>
</head>
<body>
    <div id="middle-wrapper">
    <div id="column1-wrapper">
        <div id="column2-wrapper">  <!-- Must be first -->
            This has to be 250px wide
        </div>
        This has to be 100% - 250px wide
    </div>
</div>
</body>
</html>

Not sure if it's what you're after.

Kaze no Koe
For that I'll first have to place the right div above left div in source order but that creates another problem... if left column is taller, some of its content will get placed below right column.
Salman A
I removed an earlier, retarded comment I made. Sorry, don't have a solution for that.
Kaze no Koe
+1  A: 

Two columns with color.

Svish
That's not fluid, unless I'm missing something
Kaze no Koe
You must be missing something. It is fluid here. Only difference from your question is that it is not 100% wide, and it is the right column that is fluid instead of the left one. But if you look right after the last step, two variations are actually described there. One for 100% wide and one for having column on the other side :)
Svish
Ummm, it requires me to rearrange the order of columns... i.e. the right content should be placed *before* the main content, something that'll disturb the HTML+ASP code in the existing pages.
Salman A
Haven't really done any ASP.Net, but I thought they had master pages or something for that?
Svish
You're right, sorry
Kaze no Koe
This works if I change the div order i.e. put the right column before left in the source order. Changing the div order was not desired but I can live with it for now.
Salman A
Good to hear :)
Svish
A: 

This is very close to a layout that I've searched everywhere for so thank you! One addl. question, taking the code above as the example how would one make sure that the 100%-250px column never is smaller than say 730px?

Mrmartinblue
Try using a CSS rule: `min-width: 730px`
Salman A