HTML'溢出和清除浮動的區別是什麼?
<ul>
<li>
<button>first part</button>
</li>
<li>
<button>second part</button>
</li>
<li>
<button>third part</button>
</li>
</ul>
<div id="bottom">Believe Me</div>
CSS
body {
font-size: 16px;
}
li {
list-style: none;
width: 300px;
border: 1px solid black;
margin-top: 20px;
overflow: hidden;
}
li button {
padding: 15px 10px;
margin: 2px;
display: block;
float: right;
}
div#bottom {
width: 100px;
height: 50px;
line-height: 50px;
background-color: red;
margin-top: 50px;
}
我們經常使用下面的類來清除 '浮動';
.clearfix{
clear:both;
overflow: hidden;
contain: '';
}
有時候,我們只能用'溢出',那可以解決我們的問題。
'overflow'和'clear'之間有什麼區別?
[clearfix hack和overflow:hidden vs overflow:auto?](http:// stackoverflow。com/questions/1642565/what-is-different-between-clearfix-hack-and-overflowhidden-vs-overflowauto) – dippas