This link has been bookmarked by 358 people . It was first bookmarked on 24 Oct 2008, by Glenn M.
-
04 Apr 17
-
02 Feb 17
-
A floated container div will always be the height of it's floated contents
-
-
03 Sep 16
-
10 Apr 16
Nathan Showalter"Equal Height Columns with Cross-Browser CSS"
-
03 Mar 16
-
20 Jan 16
-
28 Oct 15
-
24 Sep 15
-
17 May 15
-
28 Jan 15
Irina SokolovskajaCreating equal height columns with CSS is not as easy as it may first seem. This tutorial highlights the display problems that occur with multiple column layouts, and then shows a simple solution that works in all common web browsers. via Pocket
-
13 Dec 14
-
03 Dec 14
-
05 Nov 14
-
04 Sep 14
-
11 Aug 14
-
11 Apr 14
-
23 Mar 14
-
27 Dec 13
-
14 Nov 13
-
10 Nov 13
-
01 Nov 13
-
16 Sep 13
-
24 Aug 13
-
31 Jul 13
-
06 Jul 13
-
07 May 13
-
14 Apr 13
-
A floated container div will always be the height of it's floated contents
-
-
13 Apr 13
-
08 Apr 13
-
20 Mar 13
-
16 Dec 12
-
15 Nov 12
-
24 Oct 12
-
two divs for each column
-
instead of one
-
first div
-
o hold the content
-
the background colour. This separation gives us individual control over these elements plus we
-
the background colour
-
that div contains all the columns
-
the container to be the height of the tallest column
-
In the example above the three content columns are inside a container div.
<div id="container1"> <div id="col1">Column 1</div> <div id="col2">Column 2</div> <div id="col3">Column 3</div> </div> -
And here is the CSS that forces the container div to the height of the longest column.
-
the container div must be floated
-
each of the column content divs must also be floated
-
Floating the container makes it stretch down to the height of the tallest column inside.
-
equal height columns is to add extra containers
-
we have removed the background colours from the original columns and added them to the containers.
-
he two extra containers have been added to the HTML below.
-
All the elements are floated to the left and the containers have a width set to 100% so they stay the full width of the page.
-
he background colours have been removed from the content divs and added to the containers.
-
-
23 Oct 12
-
18 Oct 12
-
10 Sep 12
-
14 Aug 12
-
07 Aug 12
-
28 Jul 12
-
26 Jul 12
-
15 Jul 12
-
19 Jun 12
-
15 Jun 12
-
15 May 12
-
26 Apr 12
-
19 Apr 12
-
17 Apr 12
-
11 Apr 12
-
21 Mar 12
-
27 Feb 12
-
17 Feb 12
-
14 Feb 12
-
13 Feb 12
-
27 Jan 12
-
-
add extra containers
-
-
30 Dec 11
-
05 Dec 11
-
21 Nov 11
-
09 Nov 11
-
14 Oct 11
-
07 Oct 11
-
28 Sep 11
-
27 Sep 11
-
31 Aug 11
-
16 Jul 11
-
01 Jul 11
-
16 Jun 11
-
11 Jun 11
-
Three column CSS
And here is the CSS that forces the container div to the height of the longest column.
#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; } -
The process of floating the content divs makes them line up horizontally across the page. Floating the container makes it stretch down to the height of the tallest column inside.
-
Adding extra nested containers
The next step to equal height columns is to add extra containers so they are nested inside each other. We need the same number of containers as we do columns - three. These three containers are going to be the backgrounds of each column. Notice that we have removed the background colours from the original columns and added them to the containers.
Three column HTML div structure
The two extra containers have been added to the HTML below.
<div id="container3"> <div id="container2"> <div id="container1"> <div id="col1">Column 1</div> <div id="col2">Column 2</div> <div id="col3">Column 3</div> </div> </div> </div> -
Using relative positioning we now move the containers to their new locations. When each container is moved the divs become visible below.
-
Moving the content back into each column
The next thing to do is to move the content of each column back onto the page so that it aligns with the column background colour underneath. Again this is done with simple relative positioning.
And then finally we chop off the overhanging containers by adding an
overflow:hidden;rule on the outermost container - container3. -
-
-
-
-
12 May 11
-
18 Apr 11
-
05 Apr 11
-
01 Apr 11
-
17 Mar 11
-
16 Mar 11
-
17 Feb 11
-
25 Jan 11
-
04 Jan 11
-
30 Dec 10
-
17 Dec 10
-
16 Dec 10
-
14 Dec 10
-
24 Nov 10
-
23 Nov 10
-
21 Nov 10
-
11 Nov 10
-
08 Nov 10
-
28 Oct 10
-
18 Oct 10
-
12 Oct 10
-
27 Sep 10
-
22 Sep 10
-
29 Aug 10
Licious RmpaA step by step tutorial explaining how to create multicolumn layouts with divs and CSS where every column is the same height
-
26 Jul 10
-
16 Jul 10
-
15 Jul 10
-
13 Jul 10
-
08 Jul 10
-
07 Jul 10
-
15 Jun 10
Would you like to comment?
Join Diigo for a free account, or sign in if you are already a member.