Reputation: 57941
Simply draw the situation:
What I have:
----------------------------------
XXXXXXXX XXXXXXXX XXXXXXXX
XXXXXXXX XXXXXXXX XXXXXXXX
XXXXXXXX XXXXXXXX
XXXXXXXX
XXXXXXXX
----------------------------------
What I would like to have:
----------------------------------
XXXXXXXX XXXXXXXX XXXXXXXX
XXXXXXXX XXXXXXXX XXXXXXXX
XXXXXXXX XXXXXXXX XXXXXXXX
XXXXXXXX XXXXXXXX XXXXXXXX
XXXXXXXX XXXXXXXX XXXXXXXX
----------------------------------
I don't want to use display: table-cell
, because it's not cros-browser;
I don't want to use <table>
either (if it's possible).
I would like to LEARN: what is the trick of forcing floating blocks fit the contaier height ?!
PS: I try this way (this LESS code is not working, you may not pay too much attention to it)
#container {
width: 100%;
overflow: hidden;
div {
float:left;
width: 33.3%; /*only three of them. It's strange, but this is what works: 31%*/
min-height: 100%; /*unfortunutely not works */
height: 100%;
background: red;
}
}
<div id="container">
<div><div>
<div><div>
<div class="last"><div>
</div>
Upvotes: 1
Views: 101
Reputation: 66
Does the container has a height? If not, that may be the reason for the 100% not working.
Upvotes: 1
Reputation: 12060
Check this demo here: http://jsfiddle.net/FDm9F/3/embedded/result/
If you zoom, you can see that the table's height is always 100%
HTML
<table cellpadding="0" cellspacing="0">
<tr>
<td>a</td>
<td>a</td>
<td>a</td>
</tr>
</table>
CSS
html, body{
width: 100%;
height: 100%;
}
table{
width: 300px;
height: 100%;
min-height:100%;
}
table tr td{
width:33.3%;
height: 100%;
background: #F00;
border-left: 1px solid #000;
text-align:center
}
Upvotes: 2
Reputation: 53248
For a pure hack-free solution, you could wrap the columns in a second container, as discussed here:
http://matthewjamestaylor.com/blog/equal-height-columns-cross-browser-css-no-hacks
Upvotes: 2