Results 1 to 7 of 7

Thread: CSS LiqLay #2.1 Clear Float Issues

  1. #1
    Join Date
    Oct 2007
    Posts
    17
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default CSS LiqLay #2.1 Clear Float Issues

    I am using this code to create my 2 column layout. The problem is that, sometimes in my main content area I want to use floats. However, when I clear those floats (<div style='clear:both'/>) within the Content Column, the left column disappears completely in both IE and Firefox.

    Any way around this?

    Code:

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Dynamic Drive: CSS Liquid Layout #2.1- (Fixed-Fluid)</title>
    <style type="text/css">
    
    body{
    margin:0;
    padding:0;
    line-height: 1.5em;
    }
    
    b{font-size: 110%;}
    em{color: red;}
    
    
    #topsection{
    background: #EAEAEA;
    height: 90px; /*Height of top section*/
    }
    
    #topsection h1{
    margin: 0;
    padding-top: 15px;
    }
    
    #contentwrapper{
    float: left;
    width: 100%;
    }
    
    #contentcolumn{
    margin-left: 200px; /*Set left margin to LeftColumnWidth*/
    background-color:Aqua;
    }
    
    #leftcolumn{
    float: left;
    width: 200px; /*Width of left column*/
    margin-left: -100%;
    background: #C8FC98;
    }
    
    #footer{
    clear: left;
    width: 100%;
    background: black;
    color: #FFF;
    text-align: center;
    padding: 4px 0;
    }
    
    #footer a{
    color: #FFFF80;
    }
    
    .innertube{
    margin: 10px; /*Margins for inner DIV inside each column (to provide padding)*/
    margin-top: 0;
    }
    
    </style>
    
    <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)]+" ")
    }
    </script>
    
    </head>
    <body>
    <div id="maincontainer">
    
    <div id="topsection"><div class="innertube"><h1>CSS Liquid Layout #2.1- (Fixed-Fluid)</h1></div></div>
    
    <div id="contentwrapper">
    <div id="contentcolumn">
    <div class="innertube">
    
      <!-- My Code -->
      <div style="float:left;width:50%;background-color:orange;">
        Left Column
      </div>
      <div style="float:left;width:50%;background-color:pink;">
        Right Column  
      </div>
      <div style="clear:both;"/>
    
      
    </div>
    </div>
    </div>
    
    <div id="leftcolumn">
    <div class="innertube"><b>Left Column: <em>200px</em></b> <script type="text/javascript">filltext(15)</script></div>
    
    </div>
    
    <div id="footer"><a href="http://www.dynamicdrive.com/style/">Dynamic Drive CSS Library</a></div>
    
    </div>
    </body>
    </html>

  2. #2
    Join Date
    Mar 2010
    Location
    Florida
    Posts
    512
    Thanks
    9
    Thanked 61 Times in 59 Posts

    Default

    try this. =p

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Dynamic Drive: CSS Liquid Layout #2.1- (Fixed-Fluid)</title>
    <style type="text/css">
    
    body{
    margin:0;
    padding:0;
    line-height: 1.5em;
    }
    
    b{font-size: 110%;}
    em{color: red;}
    
    
    #topsection{
    background: #EAEAEA;
    height: 90px; /*Height of top section*/
    }
    
    #topsection h1{
    margin: 0;
    padding-top: 15px;
    }
    
    #contentwrapper{
    float: left;
    width: 100%;
    }
    
    #contentcolumn{
    margin-left: 200px; /*Set left margin to LeftColumnWidth*/
    background-color:Aqua;
    }
    
    #leftcolumn{
    float: left;
    width: 200px; /*Width of left column*/
    margin-left: -100%;
    background: #C8FC98;
    }
    
    #footer{
    clear: left;
    width: 100%;
    background: black;
    color: #FFF;
    text-align: center;
    padding: 4px 0;
    }
    
    #footer a{
    color: #FFFF80;
    }
    
    .innertube{
    margin: 10px; /*Margins for inner DIV inside each column (to provide padding)*/
    margin-top: 0;
    }
    
    </style>
    
    <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)]+" ")
    }
    </script>
    
    </head>
    <body>
    <div id="maincontainer">
    
    <div id="topsection"><div class="innertube"><h1>CSS Liquid Layout #2.1- (Fixed-Fluid)</h1></div></div>
    
    <div id="contentwrapper">
    <div id="contentcolumn">
    
    
      <!-- My Code -->
      <div style="float:left;width:50%;background-color:orange;">
        Left Column
      </div>
      <div style="float:left;width:50%;background-color:pink;">
        Right Column  
      </div>
      
    
      
    </div>
    </div>
    
    
    
    <div id="leftcolumn">
    <div class="innertube"><b>Left Column: <em>200px</em></b> <script type="text/javascript">filltext(15)</script></div>
    
    </div>
    
    <div id="footer"><a href="http://www.dynamicdrive.com/style/">Dynamic Drive CSS Library</a></div>
    
    </div>
    </div>
    </body>
    </html>
    Last edited by Deadweight; 01-26-2011 at 12:28 AM.

  3. The Following User Says Thank You to Deadweight For This Useful Post:

    pinch (01-27-2011)

  4. #3
    Join Date
    Oct 2007
    Posts
    17
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default

    That solved the problem thanks. I'm seeing one more oddity with your code: If I add a header element to the top of the content area, an extra margin gets added to the top of the content area which pushes everything down. If I add any other text to the top of the content area, or even a div, this doesn't happen, but headers seem to throw things off:

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Dynamic Drive: CSS Liquid Layout #2.1- (Fixed-Fluid)</title>
    <style type="text/css">
    
    body{
    margin:0;
    padding:0;
    line-height: 1.5em;
    }
    
    b{font-size: 110%;}
    em{color: red;}
    
    
    #topsection{
    background: #EAEAEA;
    height: 90px; /*Height of top section*/
    }
    
    #topsection h1{
    margin: 0;
    padding-top: 15px;
    }
    
    #contentwrapper{
    float: left;
    width: 100%;
    }
    
    #contentcolumn{
    margin-left: 200px; /*Set left margin to LeftColumnWidth*/
    background-color:Aqua;
    }
    
    #leftcolumn{
    float: left;
    width: 200px; /*Width of left column*/
    margin-left: -100%;
    background: #C8FC98;
    }
    
    #footer{
    clear: left;
    width: 100%;
    background: black;
    color: #FFF;
    text-align: center;
    padding: 4px 0;
    }
    
    #footer a{
    color: #FFFF80;
    }
    
    .innertube{
    margin: 10px; /*Margins for inner DIV inside each column (to provide padding)*/
    margin-top: 0;
    }
    
    </style>
    
    <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)]+" ")
    }
    </script>
    
    </head>
    <body>
    
    <div id="maincontainer">
      <div id="topsection">
        <div class="innertube">
          <h1>CSS Liquid Layout #2.1- (Fixed-Fluid)</h1>
        </div>
      </div>
    
      <div id="contentwrapper">
        <div id="contentcolumn">
            <h1>Test</h1>
        
            <!-- My Code -->
            <div style="float:left;width:50%;background-color:orange;">
              Left Column
            </div>
            <div style="float:left;width:50%;background-color:pink;">
              Right Column  
            </div>
        </div>
      </div>
    
      <div id="leftcolumn">
        <div class="innertube"><b>Left Column: <em>200px</em></b> 
        </div>
      </div>
    
      <div id="footer"><a href="http://www.dynamicdrive.com/style/">Dynamic Drive CSS Library</a>
      </div>
    
    </div>
    
    </body>
    </html>
    Last edited by pinch; 01-26-2011 at 03:07 AM.

  5. #4
    Join Date
    Oct 2007
    Posts
    17
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default

    The problem I detailed is visible in the most recent versions of both Firefox and IE.

  6. #5
    Join Date
    Mar 2010
    Location
    Florida
    Posts
    512
    Thanks
    9
    Thanked 61 Times in 59 Posts

    Default

    Well here is something i tried and tell me if this is what u wanted

    Code:
    <div id="contentwrapper">
        <div id="contentcolumn">
            <div style="float:left;width:100%;background-color:orange;">
              Top Column
            </div>
        
            <!-- My Code -->
            <div style="float:left;width:50%;background-color:orange;">
              Left Column
            </div>
            <div style="float:left;width:50%;background-color:pink;">
              Right Column  
            </div>
        </div>
      </div>

  7. #6
    Join Date
    Oct 2007
    Posts
    17
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by Crazykld69 View Post
    Well here is something i tried and tell me if this is what u wanted

    Code:
    <div id="contentwrapper">
        <div id="contentcolumn">
            <div style="float:left;width:100%;background-color:orange;">
              Top Column
            </div>
        
            <!-- My Code -->
            <div style="float:left;width:50%;background-color:orange;">
              Left Column
            </div>
            <div style="float:left;width:50%;background-color:pink;">
              Right Column  
            </div>
        </div>
      </div>

    It was a simple issue regarding the header margins. I thought I had them set to zero but there was a typo.

    Thanks again for the feedback.

  8. #7
    Join Date
    Mar 2010
    Location
    Florida
    Posts
    512
    Thanks
    9
    Thanked 61 Times in 59 Posts

    Default

    No problem. I hope i was able to help you out

  9. The Following User Says Thank You to Deadweight For This Useful Post:

    pinch (01-27-2011)

Bookmarks

Posting Permissions

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