This link has been bookmarked by 250 people . It was first bookmarked on 14 Mar 2006, by Yuriy Piskun.
-
03 May 12
-
when you use
<div>s to section your markup, then apply CSS to create a columnar layout. One column may be longer than the other (see Figure 1). Depending on the amount of content contained, it becomes difficult to create a layout with two equally tall columns when a unique background color is desired for each column.
-
-
18 Apr 12
-
21 Feb 12
-
14 Feb 12
-
31 Jan 12
-
29 Jan 12
-
25 Jan 12
-
14 Nov 11
-
28 Oct 11
-
05 Oct 11
-
14 Jul 11
-
17 Jun 11
-
31 May 11
-
The embarassingly simple secret is to use a vertically tiled background image to create the illusion of colored columns. For SimpleBits, my background image looks something like Figure 2 (proportions changed for demonstration), with a decorative stripey thing on the left, a wide white section for the content column, a 1 pixel border, and a light brown section for the right column’s background followed by the reverse of the left side’s decorative border.

Figure 2The whole image is no more than a few pixels tall, but when vertically tiled, it creates the colored columns that will flow all the way down to the bottom of the page — regardless of the length of content in the columns.
-
This elementary CSS rule is added to the
bodyelement:background: #ccc url(../images/bg_birch_800.gif) repeat-y 50% 0; -
It’s important to note that if borders, padding and margins are desired on either column, then we must still make up for IE/Win’s botching of the box model with Tantek Çelik’s Box Model Hack or Mid Pass Filter.
Alternatively, if borders or padding can be avoided altogether by just using margins instead, then the the Box Model Hack will not be necessary. And if the column’s content is simply sitting (transparently) on top of the tiled background, then it should be easy to avoid the hack.
-
While I use absolute positioning to create a two-column layout on my own site, equally fine results can be achieved via the
floatproperty (as seen here at ALA).The same idea applies: tile the background image, then float a column in position to overlay the faux-column backdrop behind.
-
-
04 Apr 11
-
The CSS
This elementary CSS rule is added to the
bodyelement:background: #ccc url(../images/bg_birch_800.gif) repeat-y 50% 0;Essentially, we’re making the entire page’s background color grey and tiling it vertically only (
repeat-y). The50% 0bit refers to the positioning of the background image — in this case, 50% from the left side of the browser window (resulting in a centered image) and 0 pixels from the top. -
It’s important to note that if borders, padding and margins are desired on either column, then we must still make up for IE/Win’s botching of the box model with Tantek Çelik’s Box Model Hack or Mid Pass Filter.
Alternatively, if borders or padding can be avoided altogether by just using margins instead, then the the Box Model Hack will not be necessary. And if the column’s content is simply sitting (transparently) on top of the tiled background, then it should be easy to avoid the hack.
-
-
01 Apr 11
-
29 Mar 11
-
20 Mar 11
-
13 Mar 11
-
11 Mar 11
-
22 Feb 11
-
16 Dec 10
-
12 Dec 10
-
21 Oct 10
-
20 Oct 10
-
19 Oct 10
-
18 Oct 10
-
13 Oct 10
-
08 Oct 10
-
29 Sep 10
-
28 Sep 10
-
19 Sep 10
-
23 Jul 10
-
28 Jun 10
-
17 May 10
-
12 May 10
-
11 May 10
-
27 Apr 10
-
06 Apr 10
-
18 Feb 10
-
08 Feb 10
-
22 Jan 10
-
21 Jan 10
Amanda Sagewith a decorative stripey thing on the left, a wide white section for the content column, a 1 pixel border, and a light brown section for the right column’s background followed by the reverse of the left side’s decorative bord
-
13 Dec 09
-
12 Dec 09
Eric BellotL'article original expliquant la technique des colonnes factices. Il s'agit d'une méthode pour créer l'illusion que les colonnes d'un gabarit HTML/CSS aient toutes la même hauteur quelque soit la longueur de leur contenu.
-
30 Nov 09
-
28 Nov 09
-
24 Nov 09
-
22 Nov 09
-
03 Nov 09
-
16 Oct 09
-
30 Jul 09
-
29 Jul 09
-
06 Jul 09
-
29 Jun 09
-
27 Jun 09
Gustavo PereiraIt’s a beginning CSS designer’s nightmare and a frequently asked question at ALA: Multi-column CSS layouts can run into trouble when one of the columns stops short of its intended length. Here’s a simple solution.
-
02 Apr 09
-
25 Mar 09
-
16 Mar 09
-
09 Mar 09
-
27 Feb 09
-
20 Feb 09
-
05 Feb 09
Lee HowardThis column offers a helpful "cheat" for programmers seeking to have a vertical background color extend all the way down the page. A quirk in CSS sometimes results in making it difficult for columns to extend the full length. The solution is to create a vertically tiled background image that "forces" vertical columns to extend all the way.
-
28 Jan 09
-
20 Jan 09
-
17 Jan 09
-
16 Jan 09
-
06 Jan 09
-
19 Dec 08
-
13 Oct 08
-
05 Oct 08
-
22 Sep 08
-
17 Sep 08
Michael MulichA simple method of making CSS columns appear equal in length, regardless of the content that they contain.
-
25 Aug 08
-
18 Jun 08
-
29 May 08
-
20 May 08
Bill Wolff“Faux Columns” by Dan Cederholm of SimpleBits discusses “[a] simple way to make CSS columns appear equal in length, regardless of the content that they contain.” This technique requires a good amount of skill in positioning elements on a page and understanding the nuances of the background image.
I’d like to try it, but don’t anticipate using it any time in the near future, but because we’re using Wordpress I’m not sure I’ll be needing to any time soon. -
09 May 08
-
02 May 08
-
21 Apr 08
-
18 Apr 08
Perttu PiirtoA simple method of making CSS columns appear equal in length, regardless of the content that they contain.
-
05 Apr 08
-
01 Apr 08
-
31 Mar 08
-
26 Mar 08
-
21 Mar 08
-
09 Mar 08
-
03 Mar 08
-
15 Feb 08
-
09 Feb 08
-
08 Feb 08
-
28 Jan 08
-
25 Jan 08
-
How do you get the right column’s background color to extend all the way down the page?
-
Vertical stretch
-
-
04 Jan 08
-
22 Dec 07
-
22 Nov 07
-
06 Nov 07
-
04 Nov 07
Page Comments
Would you like to comment?
Join Diigo for a free account, or sign in if you are already a member.