【发布时间】:2010-05-03 01:54:12
【问题描述】:
我需要一个高度正好为 1em 减去 1px 的 div。这可以在大多数浏览器中实现,如下所示:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<style type="text/css">
.helper {
/* background-color: black; */
position: absolute;
top: 5em;
left: 5em;
width: 2em;
height: 1em;
}
.target {
background-color: #89f;
position: absolute;
top: 0;
bottom: 1px;
width: 100%;
}
</style>
</head>
<body>
<div class="helper">
<div class="target"></div>
</div>
</body>
</html>
“目标”div 具有所需的高度。问题是,这在 IE6 中不起作用,因为它在设置 top 时忽略了 bottom 属性(一个众所周知的问题)。
是否有适用于 IE6 的解决方法(可能有多个嵌套的 div,带有边框/填充/边距/其他),还是 JavaScript 是唯一的解决方案?
请注意,我不能使用 Quirks 模式。
【问题讨论】:
-
直到 IE6 和无怪癖模式组合为止,我一直在使用。我的同情,并保持你的下巴。微软今年夏天将完全放弃对 IE6 的支持。 :)
-
@Robusto:我希望他们能让它自行卸载 ;-)
-
@chris_I:卸载自己并将自己踢到路边。 =)
-
亚马逊和谷歌也与许多其他公司一起放弃了它。 idroppedie6.com
-
@Rob:我已经计划在我可以放下它的那一天举行一个盛大的派对......在那之前,我迫切需要一个解决方案(即使它只是一个像素:)
标签: css internet-explorer-6 height