当前位置: 代码迷 >> HTML/CSS >> CSS after扫除浮动
  详细解决方案

CSS after扫除浮动

热度:181   发布时间:2012-09-01 09:33:03.0
CSS after清除浮动

例如:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<style>
.clear{zoom:1;}
.clear:after {display:block; clear:both; content:" "; visibility:hidden; height:0; line-height:0;}

</style>
</head>

<body>
	<div style=" border:1px solid #6F0;" class="clear">
    	<div style="float:left; background:#000; width:50px; height:50px;"></div>
        <div style="float:left; background:#00C; width:50px; height:50px;"></div>
        <div style="float:left; background:#900; width:50px; height:50px;"></div>
    </div>
</body>
</html>

CSS 样式部分注意:

?

.clear{zoom:1;}
.clear:after {display:block; clear:both; content:" "; visibility:hidden; height:0; line-height:0;}

  相关解决方案