代码示例:(标识:css_float_boxes)
<!DOCTYPE html>
<html>
<head>
<style>
* {
  box-sizing: border-box;
}

.box {
  float: left;
  width: 33.33%;
  padding: 50px;
}

.clearfix::after {
  content: "";
  clear: both;
  display: table;
}
</style>
</head>
<body>

<h1>网格框</h1>

<p>并排浮动的框:</p>

<div class="clearfix">
  <div class="box" style="background-color:#bbb">
  <p>框中的一些文本。</p>
  </div>
  <div class="box" style="background-color:#ccc">
  <p>框中的一些文本。</p>
  </div>
  <div class="box" style="background-color:#ddd">
  <p>框中的一些文本。</p>
  </div>
</div>

<p>请注意,我们还用了 clearfix hack 来处理布局流,并添加了 box-sizing 属性,以确保框不会由于额外的内边距(填充)而损坏。尝试删除此代码以查看效果。</p>

</body>
</html>
运行结果: