'Equal height CSS columns
Using Equal Height Columns with Cross-Browser CSS example
HTML:
<div id="container1">
<div id="col1">Column 1<br/>2</div>
<div id="col2">Column 2</div>
<div id="col3">Column 3</div>
</div>
CSS:
#container1 {
float:left;
width:100%;
}
#col1 {
float:left;
width:30%;
background:red;
}
#col2 {
float:left;
width:40%;
background:yellow;
}
#col3 {
float:left;
width:30%;
background:green;
}
There are more complicated demo pages, but I am looking to use the first example for my purposes. Why isn't the example working?
Solution 1:[1]
The simplest way to do equal height columns is with display: table.
#container1 {
display: table;
width:100%;
}
#col1, #col2, #col3 {
display: table-cell;
}
#col1 {
width:30%;
background:red;
}
#col2 {
width:40%;
background:yellow;
}
#col3 {
width:30%;
background:green;
}
Solution 2:[2]
maybe this will work? by setting a fixed height of the container div and then setting the col divs to 100%?
#container1 {
float:left;
width:100%;
height:50px;
}
#col1 {
float:left;
width:30%;
background:red;
height:100%;
}
#col2 {
float:left;
width:40%;
background:yellow;
height:100%;
}
#col3 {
float:left;
width:30%;
background:green;
height:100%;
}
example http://jsfiddle.net/squinny/dps4f/1/
idk if this will help you or not?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | cimmanon |
| Solution 2 | squinny |
