gpt4 book ai didi

底部对齐内容的 CSS 布局问题

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

我正在尝试创建一个基于 CSS 的布局,它具有:

- A dynamically sized banner.
- A content area that should use all available space.
- A footer that aligns against the bottom of the page.

目前,我有这个。但是,我的挑战是在内容领域工作。在内容区域内,我需要显示:

- A dynamically sized header.
- A content area that uses all available space.
- A footer that aligns at the bottom of the content area, but above the footer mentioned above.

总而言之,我想创建一个如下所示的屏幕:

+------------------------------------+
| Banner |
| |
|------------------------------------|
| Header |
|------------------------------------|
| Some Content |
| This needs to be dynamically sized |
| to fill all remaining content |
|-------------------------------------
| Toolbar |
|------------------------------------|
| Footer |
+------------------------------------+

目前,我有以下内容

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script src="http://code.jquery.com/jquery-1.7.1.min.js" type="text/javascript"></script>

<style type="text/css">
html, body{
height: 100%;
overflow: hidden;
}

body {
padding: 0;
margin: 0;
font-size: .85em;
font-family: Arial, Verdana;
color: #232323;
background-color: #fff;
}
</style>
</head>
<body>
<div id="banner" style="width:100%; background-color:Black; color:White;">[Banner]</div>

<div id="content" style="width:100%; height:100%; background-color:Gray; margin:0px 8px 0px 8px;">
<h2>Header</h2>

<div id="contentArea">
<div id="mainContent" style="background-color:Silver;">The main content goes here.</div>
</div>

<div id="toolbar" style="padding:8px 0px 8px 8px;">
<input type="button" id="refreshButton" value="Refresh" />
<input type="button" id="addButton" value="Add" />
</div>
</div>

<div id="statusBar" style="background-color:black; color:White; width:100%; position:fixed; bottom:0;">
<table border="0" cellpadding="0" cellspacing="0" style="width:100%;">
<tr>
<td style="width:33%;">Info</td>
<td style="text-align:center; width:34%;">Message</td>
<td style="text-align:right; width:33%;">Miscellaneous</td>
</tr>
</table>
</div>
</body>
</html>

虽然此屏幕未按预期呈现。据我所知,当我将“内容”div 高度设置为 100% 时,这意味着整个屏幕的 100%。此外,我似乎无法让“contentArea”div 占用剩余空间,也无法让工具栏与底部对齐。我究竟做错了什么?我该如何实现?

最佳答案

这种“粘性页脚”技术应该有助于解决页脚问题。它会使它粘在底部,但不会像 position:absolute 那样重叠内容,如果页面滚动。

http://ryanfait.com/sticky-footer/

关于底部对齐内容的 CSS 布局问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8419246/

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