Use clear div as the divider : clear « Layout « HTML / CSS






Use clear div as the divider

 

<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Enclosing Floats</title>
<style type="text/css">
.clear {
  clear: both;
}

.news {
  background-color:#eaeaea;
  border: solid 1px #999;
  width: 500px;
  margin-top: 10px;
}

.news img {
  float: left;
  padding: 10px 0 10px 10px;
}

.news p {
  float: right;
  width: 350px;
  margin: 0;
  padding: 10px 10px 10px 0;
}

.clearfix:after {
  content: ".";
  height: 0;
  visibility: hidden;
  display: block;
  clear: both;
}
</style>
</head>

<body>

<div class="news">
<p>day.</p>
</div>

<div class="clear">ads</div>

<div class="news">
<p>day.</p>
<div class="clear"></div>
</div>
<div class="news clearfix">
<p class="">day.</p>
</div>
<p>Blah, blah</p>
</body>
</html>

 








Related examples in the same category

1.Clear left
2.left clear to start a new line
3.clear right
4.clear: both
5.float: right and clear right
6.clear right and float right
7.clear left only
8.The clear property cancels the floating effects, and stop the wrapping.