gpt4 book ai didi

html - 简单的html css block 结构,不能为content div使用-headerHeight bottom-margin来避免滚动条?

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

以下是我简单的html/css结构:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>de titel</title>
<style type="text/css">
* {
color: #FFFFFF;
margin: 0;
padding: 0;
}
html, body {
height: 100%;
background-color: #000000;
}
#wrapper {
width: 800px;
height: 100%;
margin-left: auto;
margin-right: auto;
}
#header {
background-color: lightblue;
position: absolute;
top: 0;
width: 800px;
border: 1px solid red;
height: 60px;
}
#content {
height: 100%;
margin-top: 60px;
margin-bottom: -60px;
}
#menu {
width: 200px;
height: 100%;
border: 1px solid red;
background-color: gray;
float: left;
padding: 5px 0 0 5px;
}
#text {
background-color: orange;
height: 100%;
margin-left: 200px;
padding-top: 5px;
padding-left: 15px;
margin-right: -2px;
border: 1px solid red;
}
</style>
</head>
<body>
<div id="wrapper">
<div id="header">
<br><center>[ hier moet een header image worden toegevoegd ]</center>
</div>
<div id="content">
<div id="menu">
Link 1
</div>
<div id="text">
<h1>Titel</h1>
<p>Dit is de tekst van je pagina.</p>
</div>
</div>
</div>
</body>
</html>

我的问题是:“为什么不是 bottom-margin: -60px; 导致内容层减少 60 像素高度,以至于滚动条不显示,因为标题?我应该如何解决这个问题最干净的方式?”

提前致谢。

最佳答案

这是我的看法。

请注意 doctype 中的变化(为了简单起见,我在这里使用 HTML5 doctype,因为它会在所有浏览器中触发标准模式)请务必始终使用标准模式 doctype,除非您正在准备处理怪癖模式的 hell 。

    <!DOCTYPE html>
<html>
<head>
<title>de titel</title>
<style type="text/css">
* {
color: #FFFFFF;
margin: 0;
padding: 0;
}
html, body {
height: 100%;
background-color: #000000;
}
#wrapper {
width: 800px;
height: 100%;
margin-left: auto;
margin-right: auto;
position:relative; /* added this */
}
#header {
background-color: lightblue;
position: absolute;
top: 0;
width: 800px;
border: 1px solid red;
height: 60px;
}
#content {
/*removed these*/
/*height: 100%;
margin-top: 60px;
margin-bottom: -60px;*/
/* added these */
width:100%;
position:absolute;
top:60px;
bottom:7px;
}
#menu {
width: 200px;
height: 100%;
border: 1px solid red;
background-color: gray;
float: left;
padding: 5px 0 0 5px;
}
#text {
background-color: orange;
height: 100%;
margin-left: 200px;
padding-top: 5px;
padding-left: 15px;
margin-right: -2px;
border: 1px solid red;
}
</style>
</head>
<body>
<div id="wrapper">
<div id="header">
<br><center>[ hier moet een header image worden toegevoegd ]</center>
</div>
<div id="content">
<div id="menu">
Link 1
</div>
<div id="text">
<h1>Titel</h1>
<p>Dit is de tekst van je pagina.</p>
</div>
</div>
</div>
</body>
</html>

关于html - 简单的html css block 结构,不能为content div使用-headerHeight bottom-margin来避免滚动条?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1808318/

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