Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

keeping div containers the same length

  • 06-11-2012 12:06AM
    #1
    Registered Users, Registered Users 2 Posts: 5,228 ✭✭✭


    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: 9,206 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, Registered Users 2 Posts: 1,082 ✭✭✭Feathers


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

    HTH.


  • Registered Users, Registered Users 2 Posts: 5,228 ✭✭✭paulbok


    Cheers Feathers, that's worked for me.


Advertisement