---
title: "清除浮动的两种解决方案"
author: "luyou3415"
date: "2012-08-23T11:26:00Z"
tags: []
slug: "untitled"
draft: false
lastmod: "2012-11-29T09:44:17Z"
id: 1737935
url: "https://iluyou.iteye.com/blog/1737935"
---

&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-

transitional.dtd"&gt;  
&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;  
&lt;head&gt;  
&lt;meta http-equiv="Content-Type" content="text/html; charset=gb2312" /&gt;  
&lt;title&gt;清除浮动的两种解决方案&lt;/title&gt;  
&lt;style type="text/css"&gt;  
ul{  
list-style:none;  
height:auto;  
margin:0;  
padding:0;  
background-color:#436973;  
}  
li{  
float:left;  
width:80px;  
height:120px;  
background-color:#83B1DF;  
}  
.demo{  
clear:both;  
border:1px solid #FF00FF;  
margin-bottom:5px;  
}  
.overflow{  
height:auto;  
\_height:200px;  
min-height:200px;  
overflow:auto;  
zoom:1;  
\_overflow:visible;  
}  
.clear:after {  
content: ".";  
display: block;  
height: 0;  
clear: both;  
visibility: hidden;  
}/\*for w3c\*/  
.clear {  
zoom:1;  
}/\*for IE\*/  
&lt;/style&gt;  
&lt;/head&gt;  
&lt;body&gt;  
&lt;div class="demo"&gt;  
&lt;ul class="overflow"&gt;  
&lt;li&gt;1&lt;/li&gt;  
&lt;li&gt;2&lt;/li&gt;  
&lt;li&gt;3&lt;/li&gt;  
&lt;li&gt;4&lt;/li&gt;  
&lt;li&gt;5&lt;/li&gt;  
&lt;li&gt;6&lt;/li&gt;  
&lt;li&gt;7&lt;/li&gt;  
&lt;li&gt;8&lt;/li&gt;  
&lt;li&gt;9&lt;/li&gt;  
&lt;/ul&gt;  
&lt;/div&gt;  
&lt;div class="demo"&gt;  
&lt;ul class="clear"&gt;  
&lt;li&gt;1&lt;/li&gt;  
&lt;li&gt;2&lt;/li&gt;  
&lt;li&gt;3&lt;/li&gt;  
&lt;li&gt;4&lt;/li&gt;  
&lt;li&gt;5&lt;/li&gt;  
&lt;li&gt;6&lt;/li&gt;  
&lt;li&gt;7&lt;/li&gt;  
&lt;li&gt;8&lt;/li&gt;  
&lt;li&gt;9&lt;/li&gt;  
&lt;/ul&gt;  
&lt;/div&gt;  
&lt;/body&gt;  
&lt;/html&gt;