Several people have inquired about how to correctly use floats (e.g. How to float divs with in divs on a page).
The code below show a simple layout for floating three divs inside a container.
**Please note this layout is not limited to divs, floats can be used with a wide variety of page elements (P, UL, A, IMG, etc.)
Enjoy. PM me if you have any questions.
HTML
CSS
The code below show a simple layout for floating three divs inside a container.
**Please note this layout is not limited to divs, floats can be used with a wide variety of page elements (P, UL, A, IMG, etc.)
Enjoy. PM me if you have any questions.
HTML
HTML:
<div class="container">
<div>
<h2>Heading One</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla id nunc lacus. Integer bibendum varius fringilla. Suspendisse potenti. Donec nec tincidunt tellus. Curabitur fringilla viverra placerat. Sed quis turpis nunc.</p>
<a href="">Read more →</a>
</div>
<div>
<h2>Heading Two</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla id nunc lacus. Integer bibendum varius fringilla. Suspendisse potenti. Donec nec tincidunt tellus. Curabitur fringilla viverra placerat. Sed quis turpis nunc.</p>
<a href="">Read more →</a>
</div>
<div>
<h2>Heading Three</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla id nunc lacus. Integer bibendum varius fringilla. Suspendisse potenti. Donec nec tincidunt tellus. Curabitur fringilla viverra placerat. Sed quis turpis nunc.</p>
<a href="">Read more →</a>
</div>
</div>
<div class="container">
<div>
<h2>Heading One</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla id nunc lacus. Integer bibendum varius fringilla. Suspendisse potenti. Donec nec tincidunt tellus. Curabitur fringilla viverra placerat. Sed quis turpis nunc.</p>
<a href="">Read more →</a>
</div>
<div>
<h2>Heading Two</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla id nunc lacus. Integer bibendum varius fringilla. Suspendisse potenti. Donec nec tincidunt tellus. Curabitur fringilla viverra placerat. Sed quis turpis nunc.</p>
<a href="">Read more →</a>
</div>
<div>
<h2>Heading Three</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla id nunc lacus. Integer bibendum varius fringilla. Suspendisse potenti. Donec nec tincidunt tellus. Curabitur fringilla viverra placerat. Sed quis turpis nunc.</p>
<a href="">Read more →</a>
</div>
</div>
<div class="container">
<div>
<h2>Heading One</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla id nunc lacus. Integer bibendum varius fringilla. Suspendisse potenti. Donec nec tincidunt tellus. Curabitur fringilla viverra placerat. Sed quis turpis nunc.</p>
<a href="">Read more →</a>
</div>
<div>
<h2>Heading Two</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla id nunc lacus. Integer bibendum varius fringilla. Suspendisse potenti. Donec nec tincidunt tellus. Curabitur fringilla viverra placerat. Sed quis turpis nunc.</p>
<a href="">Read more →</a>
</div>
<div>
<h2>Heading Three</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla id nunc lacus. Integer bibendum varius fringilla. Suspendisse potenti. Donec nec tincidunt tellus. Curabitur fringilla viverra placerat. Sed quis turpis nunc.</p>
<a href="">Read more →</a>
</div>
</div>
CSS
Code:
div.container {
margin:20px auto;
border:solid 1px #ccc;
width:790px;
overflow:hidden;
position:relative;
}
div.container div {
float:left;
margin:1px 0 1px 1px;
border:solid 1px #069;
width:260px;
height:193px;
}
div.container h2, div.container p, div.container a {
font-family:Arial, Helvetica, sans-serif;
font-size:8pt;
color:#444;
padding:0 10px;
}
div.container h2 {
font-size:10pt;
line-height:25px;
}
div.container p {
line-height:15pt;
}
div.container a {
display:inline-block;
line-height:17pt;
color:#C60;
text-decoration:none;
}
div.container a:hover {
text-decoration:underline;
}