我正在使用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