我想使一個網站使用視差。無法使背景圖像全屏
我遇到了CSS的麻煩。下面是HTML:
<div id="skrollr-body">
<div class="subnav">
<ul id="nav">
<li><a href="#home">Home</a></li>
<li><a href="#foo">Foo</a></li>
</ul>
</div>
<div id="home" class="centered" data-0="height:100%;" data-1000="height:0%;" >
<div class="zebra">
<div class="contentWrap">
test
</div>
</div>
</div>
<div id="foo" class="centered" data-1000="height:100%;" data-2000="height:0%;">
<div class="world">
<div class="contentWrap">
test
</div>
</div>
</div>
</div>
這裏是CSS:
#home {
background: #dedede;
height: 100%;
z-index: 901;
}
#foo{background: yellow; z-index:800;}
.zebra {
background-image: url("/img/zebra-pattern.png");
background-position: center center;
background-repeat: repeat-x;
background-size: cover;
height: 100%;
position: relative;
width: 100%;
}
.world {
background-image: url("/img/world.jpg");
background-position: center center;
background-repeat: repeat-x;
background-size: cover;
height: 100%;
position: relative;
width: 100%;
}
.contentWrap{
position: absolute;
border: 1px solid red;
}
我的問題是,如果我不把高度明確,背景圖像不成爲全屏幕。
有什麼建議嗎?
JsFiddle會幫我處理它。 – 2013-01-06 03:33:22