gpt4 book ai didi

100% 宽度的 CSS 粘性页脚

转载 作者:行者123 更新时间:2023-11-28 12:19:17 25 4
gpt4 key购买 nike

我正在尝试实现宽度为 100% 的粘性页脚。它应该贴在页面底部,但不要与页面内容 div 重叠。我使用的页面布局与此示例相同: http://peterned.home.xs4all.nl/examples/csslayout1.html

如您所见,页脚与 div#container 的宽度相同。但我想将页脚拉伸(stretch)到 100% 宽度,同时页面内容保持居中并在调整浏览器大小时保持高度拉伸(stretch)。我该怎么做?

最佳答案

试试这个

点击文件链接查看新结果 http://jsfiddle.net/n6u3e/

/**
* 100% height layout with header and footer
* ----------------------------------------------
* Feel free to copy/use/change/improve
*/

html,body {
margin:0;
padding:0;
height:100%; /* needed for container min-height */
background:gray;

font-family:arial,sans-serif;
font-size:small;
color:#666;
}

h1 {
font:1.5em georgia,serif;
margin:0.5em 0;
}

h2 {
font:1.25em georgia,serif;
margin:0 0 0.5em;
}
h1, h2, a {
color:orange;
}

p {
line-height:1.5;
margin:0 0 1em;
}

div#container {
position:relative; /* needed for footer positioning*/
margin:0 auto; /* center, not in IE5 */
width:750px;
background:#f0f0f0;

height:auto !important; /* real browsers */
height:100%; /* IE6: treaded as min-height*/

min-height:100%; /* real browsers */
}

div#header {
padding:1em;
background:#ddd url("../csslayout.gif") 98% 10px no-repeat;
border-bottom:6px double gray;
}
div#header p {
font-style:italic;
font-size:1.1em;
margin:0;
}

div#content {
padding:1em 1em 5em; /* bottom padding for footer */
}
div#content p {
text-align:justify;
padding:0 1em;
}

div#footer {
background:#ddd;
border-top:6px double gray;
}
div#footer p {
padding:1em;
margin:0;
}
#barco{
width:750px;
margin:auto;
}

关于100% 宽度的 CSS 粘性页脚,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18966498/

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