Results 1 to 2 of 2

Thread: Centered 2 column layout with fixed width AND percentage width

  1. #1
    Join Date
    Oct 2008
    Thanked 0 Times in 0 Posts

    Default Centered 2 column layout with fixed width AND percentage width

    I need to create a centered 2 column layout using a combination of fixed width AND percentage width (and also using min and max width for the body or container).

    The body/container min/max width will be 770 to 970 pixels wide.
    The right column is 360 pixels wide.
    The left column should be stretching to fit the remaining width.

    I searched around and found a couple of solutions, but none that approached satisfying all of the above needs.

    Can anyone help?

  2. #2
    Join Date
    Jan 2006
    Ft. Smith, AR
    Thanked 129 Times in 116 Posts


    This is a code found here: that I have modified to suite your needs.

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "">
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Dynamic Drive: CSS Fixed Layout #2.2- (Fixed-Fixed)</title>
    <style type="text/css">
    line-height: 1.5em;
    b{font-size: 110%;}
    em{color: red;}
    min-width: 770px; /*Min-Width of main container*/
    max-width: 970px; /*Max-Width of main container*/
    margin: 0 auto; /*Center container on page*/
    background: #EAEAEA;
    height: 90px; /*Height of top section*/
    #topsection h1{
    margin: 0;
    padding-top: 15px;
    float: left;
    width: 100%;
    margin-right: 360px; /*Set right margin to RightColumnWidth*/
    float: left;
    width: 360px; /*Width of right column*/
    margin-left: -360px; /*Set left margin to -(RightColumnWidth) */
    background: #FDE95E;
    clear: left;
    width: 100%;
    background: black;
    color: #FFF;
    text-align: center;
    padding: 4px 0;
    #footer a{
    color: #FFFF80;
    margin: 10px; /*Margins for inner DIV inside each column (to provide padding)*/
    margin-top: 0;
    <script type="text/javascript">
    /*** Temporary text filler function. Remove when deploying template. ***/
    var gibberish=["This is just some filler text", "Welcome to Dynamic Drive CSS Library", "Demo content nothing to read here"]
    function filltext(words){
    for (var i=0; i<words; i++)
    document.write(gibberish[Math.floor(Math.random()*3)]+" ")
    <!--=========BEGIN DO NOT REMOVE | THIS MAKES IE 6 RECOGNIZE MIN/MAX WIDTH=============-->
    <!--[if lt IE 7]>
    <script src="" type="text/javascript"></script>
    <!--=========END DO NOT REMOVE | THIS MAKES IE 6 RECOGNIZE MIN/MAX WIDTH=============-->
    <div id="maincontainer">
    <div id="topsection"><div class="innertube"><h1>CSS Fixed Layout #2.2- (Fixed-Fixed)</h1></div></div>
    <div id="contentwrapper">
    <div id="contentcolumn">
    <div class="innertube"><b>Content Column: <em>Fixed</em> (expands width to compensate for right column)</b> <script type="text/javascript">filltext(45)</script></div>
    <div id="rightcolumn">
    <div class="innertube"><b>Right Column: <em>360px</em></b> <script type="text/javascript">filltext(30)</script></div>
    <div id="footer"><a href="">Dynamic Drive CSS Library</a></div>
    Reviews, Interviews, Tutorials, and STUFF
    Home of the SexyBookmarks WordPress plugin


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts