【发布时间】:2012-02-02 21:48:01
【问题描述】:
我正在使用this tutorial 创建全屏背景。 (更新:对图像使用 100% 的高度和宽度不是我想要的,因为它只是拉伸图像,此脚本保持纵横比。)
我还尝试使用this tutorial 合并一个粘性页脚。
添加粘性页脚部分会在背景图像上创建一些额外的水平滚动。
我的图像是 700 像素 x 466 像素,我的浏览器窗口是 1240 x 1414。我的网站水平位于浏览器窗口的中间,但可以向右滚动一点。
如何使全屏背景图像与粘性页脚一起使用,以消除额外的水平滚动?粘性页脚需要位于背景图像的顶部而不是其下方。
更新:使用 Supr 的答案来解决水平问题,唯一需要解决的是页脚位于背景图像下方而不是在其顶部。
这是我的 CSS:
* {
margin:0;
}
html, body {
height:100%;
}
.wrapper {
min-height: 100%;
height: auto !important;
height: 100%;
margin: 0 auto -4em;
}
.footer, .push {
height: 4em;
}
.clear {
clear:both;
}
body {
font-size: 62.5%; /* Resets 1em to 10px */
background-repeat:repeat-x;
background-image: url('images/background-repeat.jpg');
margin:0px;
}
#body {
width:1000px;
margin:0 auto 0 auto;
}
.fullBg {
position: absolute;
top: 0;
left: 0;
overflow: hidden;
}
#maincontent {
position: absolute;
top: 0;
left: 0;
z-index: 50;
}
这是我的html:
<div class="wrapper">
<img src="<?php bloginfo('stylesheet_directory'); ?>/images/bg1.jpg" alt="" id="background">
<div id="maincontent">
<div id="body"></div>
<div class="push"></div>
</div>
<div id="footer">
<p><a href="/home" title="Home">Home</a> | <a href="/about" title="About">About</a></p>
</div>
</div>
【问题讨论】:
-
请向我们展示该页面或添加您的代码。