<!-- 设置clearfloat样式,让里面的div撑开外面的div,让高度自适应 -->
<style type="text/css">
.clearfloat{clear:both;height:0;font-size: 1px;line-height: 0px;}
</style>
</head>
<div class="choose-bg-box">
<c:forEach items="${focusAreasList }" var="list" varStatus="count">
<div class="choose-box" style="float:left;">
<div class="choose-box-item" id="${list.dictionaryId }" name="focusArea"> ${list.dictionaryName}</div>
</div>
</c:forEach>
<div class="clearfloat"></div>
</div>
在浮动的容器后面,父容器结束之前加入一个div,代码如下:
<div class="fuqin">
<ul>
<li>内容1</li>
<li>内容1</>
</ul>
<div class="clearfloat"></div>
</div>
.clearfloat{clear:both;height:0;font-size: 1px;line-height: 0px;}
原文地址:https://www.cnblogs.com/konglxblog/p/10012085.html