Home » Programming / Coding

Two Cloumn Equal Height Layout With CSS

11 January 2010 300 views No Comment

I wanna create a two column layout using CSS. Both clumns would have equal height. This is how we can do it:

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN”
“http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>

<html>
<head>
<title>Two Cloumn Equal Height CSS Layout</title>
<style type=”text/css”>
#container{
background-color:#fff;
overflow:hidden;
width:750px;
}
#div1{
background-color:#99cccc;
width:600px;
border-right:150px solid #c33; /* The width and color of the div2 */
margin-right:-150px;
float:left;
}
#div2{
background-color:#cc3333;
width:150px;
float:left;
}
</style>
</head>
<body>
<div id=”container”>
<div id=”div1″>This is left div 1 content<br />This is left div 1 content</div>
<div id=”div2″>This is div 2 content</div>

</div>
</body>
</html>

border-right:150px solid #c33;
This line of code just gives a color to the div2.

margin-right:-150px;
This line of code create space on the right for div2.

Other then that everything else is self explanatory.

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...

Leave your response!

Add your comment below, or trackback from your own site. You can also subscribe to these comments via RSS.

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

This is a Gravatar-enabled weblog. To get your own globally-recognized-avatar, please register at Gravatar.