更新时间:2023-10-25 09:45:22
>设置 #upperDiv
以下任一项:
overflow: hidden;
width: 100%;
或
float: left;
width: 100%;
或使用CSS伪元素(IE8 + compatible)创建规则,如下所示
or create a rule using CSS pseudo-elements (IE8+ compatible) like this
#upperDiv:after {
content: "";
display: table;
clear: both;
}
***解决方案
创建一个可重用的类规则,如下所示。
Best solution
Creating a reusable class rule like the following.
.group:after {
content: "";
display: table;
clear: both;
}
现在,您可以将它应用于需要相同功能的任何东西。例如...
Now you can apply it to anything that needs this same functionality. For example...
<div id='upperDiv' class="group" ... >
如果您需要IE 6/7兼容性,请此帖。
P.S. If you require IE 6/7 compatibility, checkout this post.