gpt4 book ai didi

html - 窗口 div 超出页脚

转载 作者:太空宇宙 更新时间:2023-11-04 15:38:20 26 4
gpt4 key购买 nike

我一直在努力使我的网站具有均匀边距的 wrapper ,但底部边距总是太大。为了隔离这个问题,我注释掉了 html 中的所有 div 内容,并注释掉了所有与基本 div 无关的 css 选择器,但窗口 div 仍然会越过页脚。

这是 css,您会注意到一些 css 属性以 s 开头拼写错误。不用担心这些,这只是我注释掉 css 属性的一种快速方法。

.window {
width: 88%;
height: 99%;
smargin-top: 3%;
smin-height: 800px;
margin-left: 7%;
sbox-shadow: 0px 0px 10px 1px #000000;
min-width: 1110px;
background-color: #FF0000;
}
.header {
height: 15%;
width: 100%;
background-color: #DDDDDD;
padding-top: 1%;
smin-height: 100px;
}
.nav {
font-size: 20px;
spadding-top: 1%;
height: 5%;
width: 100%;
background-color: #999999;
font-family: Tahoma, Geneva, sans-serif;
smin-height: 35px;
max-height: 40px;
}
.content {
height: 60%;
width: 100%;
smin-height: 350px;
: ;
spadding-top: 3%;
background-color: #FFFFFF;
}
.footer {
font-family: Arial, Helvetica, sans-serif;
height: 5%;
width: 100%;
background-color: #DDDDDD;
smin-height: 30px;
}

这是 html,我排除了所有注释掉的内容,这样问题就可以从它的基本结构中分离出来。

<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Excercise 2 CSS</title>
</head>

<body>
<div class="window">
<div class="header">

</div>
<div class="nav">

</div>
<div class="content">

</div>
<div class="footer">

</div>
</div>
</body>
</html>

最佳答案

您的添加不正确。在您的 CSS 中,您的高度为:页眉 15%、导航 5%、内容 60% 和页脚 5%,加在一起时仅等于 85%。我不确定填充会如何影响这样的布局,但如果你应用 box-sizing: border-box;对于你的 div,填充不会影响整体大小(将减法而不是加法)

更正后的代码在下面(虽然我删除了你的大部分其他 css)

html, body
{
height: 100%;
}

.window {
height: 100%;
width: 100%;
background-color: #FF0000;
}
.header {
height: 15%;
background-color: #DDDDDD;
}
.nav {
height: 5%;
background-color: #999999;
}
.content {
height: 75%;
background-color: #FFFFFF;
}
.footer {
height: 5%;
background-color: #DDDDDD;
}​

关于html - 窗口 div 超出页脚,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12501364/

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