HTML and CSS Reference
In-Depth Information
Using overflow to Control Floats
The final method is so head-slappingly simply that you'll wonder why it took so long to discover
(and you can thank one of the folks at SitePoint, www.sitepoint.com/blogs/2005/02/26/
simple-clearing-of-floats/ , for this idea). We'll highlight the significant parts in the follow-
ing code:
<!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">
<head>
<title>Overflow auto method demonstrated</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<style type="text/css">
#parent1 {
border:5px solid purple;
padding:10px;
overflow:auto;
width:100%;
}
.floatleft {
border:5px solid red;
float:left;
width:200px;
background:white;
}
.floatright {
border:5px solid green;
float:right;
width:200px;
background:white;
}
</style>
</head>
<body>
<div id="parent1">
<p>This is the first parent container</p>
<p class="floatleft">This is floated content. </p>
<p class="floatright">This is floated content. </p>
</div>
</body>
</html>
Search WWH ::




Custom Search