HTML Element Style How to - Fill background of aligned blocks








Question

We would like to know how to fill background of aligned blocks.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
.clearfix:before, .clearfix:after {<!--  www.j  a v a2s .c om-->
  content: ".";
  display: block;
  height: 0;
  overflow: hidden;

}

.clearfix:after {
  clear: both;
}

.clearfix {
  zoom: 1;
  background-color: Aqua;
} /* IE < 8 */
</style>
</head>
<body>
  <div class="clearfix">
    <div style="float: left">left</div>
    <div style="float: right">right</div>
  </div>
</body>
</html>

The code above is rendered as follows: