固定背景滚动效果

时间:2013-10-28 15:12:45

标签: css css3 background scroll

简短问题:如何使用css实现此滚动效果? - >

http://focuslabllc.com/

我已经尝试过了:

#one {
    background: url(http://images.buzzillions.com/images_products/07/02/iron-horse-    maverick-elite-mountain-bike-performance-exclusive_13526_100.jpg);
    background-repeat: no-repeat;
    background-position: center center;
    background-attachment:fixed;
}

#two {
    background: url(http://img01.static-nextag.com/image/GMC-Denali-Road-Bike/1/000/006/107/006/610700673.jpg);
    background-repeat: no-repeat;
    background-position: center center;
    background-attachment:fixed;
}

谢谢! :)

2 个答案:

答案 0 :(得分:5)

它被称为“幕布揭示”,但在这种情况下它反过来。 http://www.thecssninja.com/css/reveal-effect

基本上,第一个“幻灯片”位于所有其他内容的“下方”,并设置为position: fixed并说z-index: 1,其他所有内容都设置为position: relative和{{1} }

http://jsfiddle.net/3n1gm4/8gDDy/

因此在代码中它将是

HTML

z-index: 10

CSS

<div class="slide1">CONTENT</div>
<div class="slide2">CONTENT</div>

* 这很快就完成了,可能不是100%准确,但旨在让您了解最新情况。

答案 1 :(得分:4)

好的,你可以用CSS做到这一点。

<强> HTML

<div class="main">Sample text/div>
<div class="reveal-me-holder"></div>
<div class="reveal-me">Revealed</div>

<强> CSS

body {
    margin:0;
}
.main {
    height: 700px; 
    position:relative;
    z-index: 2; 
    background: red;
} 
.reveal-me {
    height: 500px;
    position:fixed; 
    bottom:0; 
    width:100%;
    background: black;
    color:white;
 } 
.reveal-me-holder {
    height: 500px;
} 

jsfiddle显示结果。

相关问题