gpt4 book ai didi

ie7 中的 css 宽度 %

转载 作者:行者123 更新时间:2023-11-28 13:49:33 24 4
gpt4 key购买 nike

我有一个 100% 的父容器。它包含 2 个宽度为 50% 的 float div。子项仅包含文本。问题是子容器和文本一样宽,而不是父容器宽度的 50%。只有ie7是个问题。也许还有 ie6,但我不关心那个浏览器。

ball (width 16px position absolute)
parent (width 100% position absolute. Should be more than 16px)
child (width:50% float left)
child (width:50% float left)

有人可以帮忙吗?

最佳答案

无需 JS hack。就用右边的doctype .

复制'n'粘贴'n'运行它,检查结果,然后删除文档类型并在 IE 中重新测试。

<!doctype html>
<html lang="en">
<head>
<title>Test</title>
<style>
body { width: 300px; }
.parent { width: 100%; border: 1px solid black; overflow: hidden; }
.child { float: left; width: 50%; }
h3 { clear: left; }
</style>
</head>
<body>
<h3>Test 1</h3>
<div class="parent">
<div class="child">text</div>
<div class="child">text</div>
</div>
<h3>Test 2</h3>
<div class="parent">
<div class="child">text text text text text text text text text text</div>
<div class="child">text</div>
</div>
<h3>Test 3</h3>
<div class="parent">
<div class="child">text</div>
<div class="child">text text text text text text text text text text</div>
</div>
</body>
</html>

没有文档类型或使用非标准模式文档类型的 IE 将在 quirks mode 中呈现.

关于ie7 中的 css 宽度 %,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3076553/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com