gpt4 book ai didi

height - 最小高度 Vs 高度

转载 作者:太空宇宙 更新时间:2023-11-04 00:30:41 25 4
gpt4 key购买 nike

我目前正在尝试让 DIV 扩展到浏览器高度的 100%。我知道这是一个常见问题,因此阅读了无数论坛以找到答案,但尚未找到适用于所有浏览器的内容。

我的 CSS 文件看起来像这样:

html{height:100%;}

body {
background: #ffffff;
font-size: 0.8em;
line-height: 1.7;
color: #09123e;
height:100%;
}

#wrapper {
background: #ffffff url(../images/assets/wrapper.bg.gif) repeat-y center center;
margin: 0 auto;
height:100%;
}

这在除更高版本的 Internet Explorer(尤其是 IE7 和 IE8)之外的所有浏览器中均按预期呈现。我发现,如果我在 #wrapper 上使用 min-height 而不是高度,那么我会在有问题的浏览器中得到所需的结果,但这会扰乱其他所有内容的渲染。我曾尝试使用条件样式表,但指定的 #wrapper 样式似乎被忽略了。

如有任何帮助,我们将不胜感激。

最佳答案

这在所有浏览器中都能正常工作,确保你使用的是 doctype!

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style type="text/css">
* {margin: 0px; padding: 0px;} //Reset all margins, use some css reset stylesheet instead...
html {height: 100%;}
body {height: 100%;}
#wrapper {
margin: 0 auto;
height: 100%;
}
</style>
</head>
<body>
<div id="wrapper"></div>
</body>
</html>

关于height - 最小高度 Vs 高度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4187001/

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