Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

keeping div containers the same length

Options
  • 06-11-2012 12:06am
    #1
    Registered Users Posts: 4,941 ✭✭✭


    I have 2 div tags nested within a parent div.
    they are for a main content section & a rhs side content.
    I have them positioned correctly horizontally but the problem I'm having is than when the main content fills up more than the right content and expands down the page, the right hand content stays the same length.
    How do I set them to keep the same length?

    HTML
    < div id="container">
    
    <div id="main>
    Lorem....
    </div>
    
    <div id="rightside">
    lpsum...
    </div>
    </div>
    
    CSS
    #main {
    float: left;
    width: 760px;
    height: 100%;
    position: relative;
    }
        
    /* All Right side Styles */
    #rightside {
    float: right;
    position: relative; 
    width: 198px;
    height: 100%;
    }
    
    #container {
    clear:both;
    }
    


Comments

  • Closed Accounts Posts: 2,930 ✭✭✭COYW


    Put the text inside paragraph or span tags, depending on how long the text is and set word-wrap:break-word; tag in your #main.
    < div id="container">
    
    <div id="main>
    <span>Lorem....</span>
    </div>
    
    <div id="rightside">
    <span>lpsum...</span>
    </div>
    
    </div>
    
    CSS
    
    #main {
    float: left;
    width: 760px;
    height: 100%;
    position: relative;
    word-wrap:break-word;
    }
    
    


  • Moderators, Science, Health & Environment Moderators Posts: 8,920 Mod ✭✭✭✭mewso


    Depends on how each div is distinguished. You don't have any background colour specified but if you are using colour then give the container the background colour you want for the left hand div and float it left. Then specify a bg colour for the right side div and when it stretches it stretches the container with it giving the illusion that the left hand div is expanding.


  • Registered Users Posts: 1,082 ✭✭✭Feathers


    From the sound of it, you're looking for a Faux Columns technique.

    HTH.


  • Registered Users Posts: 4,941 ✭✭✭paulbok


    Cheers Feathers, that's worked for me.


Advertisement