gpt4 book ai didi

javascript - 如何将 3 div 显示为 "sub-header", "sub-footer", "sub-content"

转载 作者:太空宇宙 更新时间:2023-11-04 14:02:32 28 4
gpt4 key购买 nike

我需要在我的站点内创建一个子结构,我在其中拥有:

Result

实际上我是通过 Javascript 来完成的(伪代码):SUB_Content.height = ParentDiv.height - Sub_Header.height - sub_Footer.height

但这(使用 outerHeight 等)会花费很多时间。

我正在尝试使用 CSS 来实现,例如:

#REST OF THE SITE ... 100% 100%
#PARENT_DIV { width: 300px; height: 300px; border:1px solid red;}
#HEADER { background: orange; height: 63px; float:left; width: 100%; }
#CONTENT { background:blue; padding-top: 63px; height: 100%; box-sizing: border-box; }
#FOOTER { background:pink; height:50px; box-sizing: border-box; margin-top:-50px;}

即使我为页眉和页脚设置了固定大小,内容也会得到整个“父亲大小”。我无法使用 FIXED 或 ABSOLUTE 定位。

我尝试了很多方法,但一无所获。

大多数尝试给我这样的结果:

enter image description here

有没有我可以遵循的教程/Angular 色来将内容的大小固定为 100% - header.height - footer.height?

一般内容比Parent div大,放个scrollbar就可以了。我已经尝试了所有的“display:table-row”等等。

这是一个“相似”的结构:

<!DOCTYPE html>
<html>
<head>
<style>
#PARENT_DIV { width: 300px; height: 300px; border:1px solid red;}
#HEADER { background: orange; height: 63px; float:left; width: 100%; }
#CONTENT { background:blue; padding-top: 63px; height: 100%; box-sizing: border-box; overflow:auto; }
#FOOTER { background:pink; height:50px; box-sizing: border-box; margin-top:-50px;}
</style>
</head>
<body>

<div id="PARENT_DIV">
<div id="HEADER">
HUGE CONTENT
</div>
<div id="CONTENT">
VERY HUGE TABLE
</div>
<div id="FOOTER">
</div>
</div>
</body>
</html>

最佳答案

我想这就是你想要的:

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style>
#PARENT_DIV {
background-color: #333333;
border: 1px solid red;
height: auto;
padding: 28px;
position: absolute;
width: 300px;
color: #cacaca;
}

#HEADER {
background: none repeat scroll 0 0 orange;
float: left;
min-height: 63px;
width: 100%;
}

#CONTENT {
background: none repeat scroll 0 0 blue;
max-height: 500px;
min-height: 100px;
overflow: auto;
}

#FOOTER {
background: pink;
height: 50px;
box-sizing: border-box;
width: 100%;
bottom: 0;
}

body {
background-color: #bababa;
}

.clear {
clear: both;
}
</style>

</head>
<body>

<div id="PARENT_DIV">
Parent Div
<br />
<div id="HEADER">
Header
</div>
<div class="clear"></div>
<div>
<div id="CONTENT">
VERY HUGE TABLE<br />
VERY HUGE TABLE<br />
VERY HUGE TABLE<br />
VERY HUGE TABLE<br />
VERY HUGE TABLE<br />
VERY HUGE TABLE<br />
VERY HUGE TABLE<br />
VERY HUGE TABLE<br />
VERY HUGE TABLE<br />
VERY HUGE TABLE<br />
VERY HUGE TABLE<br />
VERY HUGE TABLE<br />
VERY HUGE TABLE<br />
VERY HUGE TABLE<br />
VERY HUGE TABLE<br />
VERY HUGE TABLE<br />
VERY HUGE TABLE<br />
VERY HUGE TABLE<br />
VERY HUGE TABLE<br />
VERY HUGE TABLE<br />
VERY HUGE TABLE<br />
VERY HUGE TABLE<br />
VERY HUGE TABLE<br />
VERY HUGE TABLE<br />
VERY HUGE TABLE<br />
VERY HUGE TABLE<br />
VERY HUGE TABLE<br />
VERY HUGE TABLE<br />
VERY HUGE TABLE<br />
VERY HUGE TABLE<br />
</div>
</div>
<div id="FOOTER">
Footer
</div>
</div>
</body>
</html>

注意:此外,您可以将 PARENT_DIV 的高度和宽度设置为 98% 以适合您的屏幕。

关于javascript - 如何将 3 div 显示为 "sub-header", "sub-footer", "sub-content",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21401254/

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