Reputation: 3804
Two requirement i have.
Left div have to be the same height as right div
I need a footer div.
and this is the code.
HTML
<div id="base">
<div id="leftleft">left
<br/>I WANT THIS HEIGHT TO BE SAME AS RIGHT DIV
<br/>
</div>
<div id="rightright">RIGHT DIV HEIGHT WILL BE
<br/>CHANGED DYNAMICALLY.
<br/>I WANT TO MATCH THE LEFT
<br/>AND RIGHT DIV HEIGHT EQUALLY.
<br/>right
<br/>right
<br/>right
<br/>right
<br/>right
<br/>right
<br/>right
<br/>right
<br/>
</div>
<div id="footer">
this has to be in the bottom
</div>
</div>
CSS
#leftleft {
background: #1B8BC6;
width: 100px;
height: 100%;
display: table-cell;
float:left;
}
#rightright {
display: table-cell;
float:left;
}
#footer{
clear:both;
}
#base {
height: 100%;
display: table;
position:relative;
}
Fiddle,
If I put float:left
the footer goes down, but the left div height doesn't match.
if i delete float:left
the footer div doesn't go down :(
Upvotes: 0
Views: 1025
Reputation: 371
You can try this approach.
Add height:100% to body and html(for ensure all div inside body can inherit the height).
body,html{height:100%;}
Good Luck!!
Upvotes: 0
Reputation: 463
how about using min-height in CSS of each DIV
min-height: 300px
OR
use table. In table, td tags are always in same width and height.
Upvotes: 0
Reputation: 32202
Try this code
Remove float:left;
As like this code
#base {
height: 100%;
width:100%;
display: table;
}
#leftleft {
background: #1B8BC6;
width: 100px;
height: 100%;
display: table-cell;
vertical-align:top;
}
#rightright {
display: table-cell;
vertical-align:top;
}
#footer{
display:table-row;
width:100%;background:red;
}
Upvotes: 3
Reputation: 441
use <table>
<table>
<tr>
<td>Left Div
</td>
<td>Right Div
</td>
</tr>
</table>
<footer>Footer</footer>
Upvotes: 0