【发布时间】:2025-12-26 23:40:07
【问题描述】:
HTML:
<ul>
<li>
<div class="one">Variable Height Title</div>
<div class="two">Fixed height middle block</div>
<div class="three">Variable height middle block<br />more content<br /> more contentmore content<br /> more content<br /> more content</div>
<div class="four">Fixed height footer</div>
</li>
<li>
<div class="one">Variable Height Title Might be two lines long</div>
<div class="two">Fixed height middle block</div>
<div class="three">Variable height middle block</div>
<div class="four">Fixed height footer</div>
</li>
<li>
<div class="one">Variable Height Title</div>
<div class="two">Fixed height middle block</div>
<div class="three">Variable height middle block</div>
<div class="four">Fixed height footer</div>
</li>
</ul>
CSS:
li {
float:left;
width:33%;
}
.one, .three {
background-color:blue;
}
.two, .four {
background-color:green;
}
请看这个例子:http://jsfiddle.net/WffHD/
有没有办法仅使用 css 使“一个” div 的高度相等(必须是动态的),然后还根据最高的一列使所有三列的高度相等?另一种说法:我希望所有“一个” div 的高度相同,然后通过拉伸“三个” div 的高度,所有列的高度也应该相同。不幸的是,由于我正在使用一个插件,它们必须保留为 li 项目。我认为这可以用 javascript 很容易地完成,但如果可能的话,我正在寻找一个 css 解决方案。 (警告,需要在 IE7 中工作)希望这是有道理的,谢谢!
【问题讨论】:
-
开始认为仅使用 CSS 可能无法做到这一点,可能不得不求助于 javascript。
-
IE7?您可以尝试使用 IE 的 css 行为。
-
@biziclop:IE 中的行为实际上是后门 javascript。所以它真的不是“纯 css”。
-
我们能否提供一种解决方案来保留
li的但结构不同?
标签: html css internet-explorer-7