Jump to content

variable column div


jmag

Recommended Posts

I'm actually just trying stuff out, but it would be cool to be able to do it. Lets say I've got 3 or 4 columns and I want them to float next to eachother, but one or two of them should take the leftover space and just divide it between them.

If a site is supposed to be perhaps 900px wide, and then 2 columns are 150px each. Then I want the other columns to just take up what space is left over and fill it without getting on the next line.

here's a sample of what I had in mind.

CSS:
[code]    div {
        border: 1px #000000 solid;
        padding: 3px;
        margin: 3px;
    }
    
    #header, #footer {
        width: 900px;
        clear: both;
    }
    
    #content {
        width: 900px;
    }
    
    #menu, #somespace {
        float: left;
        width: 200px;
        background-color: #eeeeee;
    }
    
    #main, #fourth {
        float: left;
        width: 200px;
        background-color: #FF0000;
    }[/code]

HTML:
[code]    <div name="header" id="header">
        header
    </div>
    
    <div name="content" id="content">
        <div name="menu" id="menu">
            menu
        </div>
        
        <div name="main" id="main">
            main content main content main content main content main content main content main content main content main content main content main content main content main content main content main content main content main content main content main content main content main content main content main content main content main content main content main content main content main content main content main content main content main content main content main content main content main content main content main content
        </div>
        
        <div name="somespace" id="somespace">
            bannerspace
        </div>
        
        <div name="fourth" id="fourth">
            fourth column
        </div>
    </div>
    
    <div name="footer" id="footer">
        footer
    </div>[/code]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.