How to make div 100% high relative to parent?

I am stuck with something like below. I need to make the right height of the div 100% (its bgcolor will cover the entire height of the main div).

<body>
    <div id="main" style="width: 800px; margin: auto; text-align: left; border: 1px solid #628221; padding: 2px; background-color: #fff;">
        <div id="left" style="float: left; width: 600px; background-color: #A7C864;">
            <div id="left-top">left-top</div>
            <div id="left-bottom">left-bottom</div>
        </div>
        <div id="right" style="float: right; width: 200px; background-color: #C7E48E;">
            <div id="right-top">right-top</div>
        </div>
        <div style="clear: both;"></div>
    </div>
</body>

Working example: http://marioosh.net/lay1.html

Using a table is easy: http://marioosh.net/lay2.html

+5
source share
2 answers

Perhaps I misunderstand the question (your link to a desktop example does not work), but it looks like you are trying to create two columns with equal height. There are several methods you can use, here are three of them:

, . , TABLE HTML-.

+5

, 100%. 100%, ,

-2

All Articles