这是我的jsFiddle。我所指的特定 CSS 在选择器上.inner div
。我的意思是“它会很糟糕”,你会在你的页面上使用它吗?你预见到它有什么问题吗?这种技术有名字吗?有没有更好的方法来实现这一点?我的目标是让两个div
s 向左浮动#one
并#two
匹配高度,如您所见,左边的水绿色一直延伸到section
.
html
<section>
<div class="inner">
<div id="one"><p>Lorem</p></div>
<div id="two">
<p>Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore</p>
</div>
</div>
<div class="clear"></div>
</section>
css
section {
width: 60%;
margin: 0 auto;
border: 1px solid red;
border-radius: 5px;
}
#one, #two {
float: left;
width: 50%;
}
#one {
background: aqua;
padding-bottom: 1000px;
}
.clear {
clear: both;
}
.inner {
overflow: hidden;
}
.inner div {
margin-bottom: -1000px;
padding-bottom: 1000px;
}