Two Column Float

From CSS Discuss

Jump to: navigation, search

One of several Float Layouts...

Here is an example of a two column float layout:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
	   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Simple 2 column layout with footer</title>
<style type="text/css">
body {
  font-family: georgia;
}
div#header {
  border-bottom: 1px solid #000;
}
div#main {
  margin-left: 20%;
}
div#menu {
  width: 15%;
  float: left;
}
div#footer {
  clear: both;
  border-top: 1px solid #000;
}
p {
  margin: 0.5em 1em;
}
</style>
</head>
<body>

<div id="header">
 <h1>The header</h1>
</div>

<div id="menu">
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit.</p>
</div>

<div id="main">
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit.</p>

<p>Quisque posuere lobortis turpis.</p>

<p>Praesent imperdiet volutpat enim.</p>

<p>Suspendisse mi pede, feugiat non, volutpat ut, placerat vitae, urna.</p>

<p>Nullam vehicula, augue id imperdiet iaculis, tellus neque commodo felis, ac aliquet risus nibh id nibh.</p>

</div>

<div id="footer">
The footer...
</div>

</body>
</html>
Personal tools