我正在使用this tutorial创建全屏幕背景。 (更新:使用高度和宽度为100%的图像是不是我想要的,因为这只是拉伸图像,此脚本保持长宽比。)使用粘性页脚的全屏幕背景?
我也试图合并一个粘脚this tutorial。
添加粘页脚部分是在背景图像上创建一些额外的水平滚动。
我的图像是700px x 466px,我的浏览器窗口是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>
,请告诉我们,页面或添加代码。 – Tim 2012-02-02 10:57:58
@Tim刚添加了代码。 – Rob 2012-02-02 11:19:44