页面滚动横幅/ jumbotron

时间:2015-10-02 14:37:30

标签: jquery html css

所以我想重新创建这个效果:http://www.firstprinceproductions.ga/ 当您开始滚动时,页面的实际内容会滚动到超大屏幕上。 到目前为止,我没有做到这一点。 这是我现在的一些代码:

HTML

<div class="jumbotron">
    <h1 style="text-shadow: 5px 5px 2px #000;">Team Divinity</h1>
        <div class="btn-group" role="group" aria-label="...">
            <button type="button" class="btn btn-default"><i class="fa fa-question"></i> About us</button>
            <button type="button" class="btn btn-info"><i class="fa fa-share"></i> Share</button>
        </div>
</div>

<div class="container">
    <div class="news">
        <div class="container">
            <h2 style="text-align: center;">News</h2>
            <div class="understroke"></div>
            <div class="col-md-3">
                <div class="thumbnail">
                    <a href="#" class="learnlink"><h3>Website V2.0</h3></a>
                    <p>We are currently working on the site, this message is currently being displayed manually but will later be displayed useing a data base</p>
                    <a href="#" class="btn btn-default">Read more</a>
                </div>
            </div>
        </div>
    </div>
    <div class="games">
        <div class="container">
            <h2 style="text-align: center;">Games</h2>
            <div class="understroke"></div>
            <div class="col-md-6">
                <div class="thumbnail">
                    <a href="#"><h3>Test 2</h3></a>
                    <a href="#"><img src="img/bg.jpg" class="thumbnail-image"></a>
                </div>
            </div>
            <div class="col-md-6">
                <div class="thumbnail">
                    <a href="#"><h3>Test</h3></a>
                    <a href="#"><img src="img/bg.jpg" class="thumbnail-image"></a>
                </div>
            </div>
        </div>
    </div>
</div>

CSS

body {
    background-color: #ebebeb;
    top: 5px;
    bottom: 5px;
    overflow-x: hidden; 
}

.navbar {
    border-bottom: none
}

.jumbotron {
    text-align: center;
    color: #ebebeb;
    background: url("/img/bg.jpg");
}

.understroke {
    width: 100%;
    height: 1px;
    background-color: #C4C4C4
}

.thumbnail {
    background: none !important;
    color: none !important;
    border: none;
    border-radius: 0;
}

.news h2 {
    font-size: 38px;

}

.news {
    background-color: none;
    margin: auto 20px;
    clear: both;
    height: auto;
}

.learnlink {
    margin-left: 0;
}

.thumbnail-image {
    border: 3px solid #000;
}

.container {
    width: 93%;

}

1 个答案:

答案 0 :(得分:0)

使用z-indexfixed:position即可实现此目的。 确保您的容器有一个顶部margin。另外,请确保将标题的宽度设置为100%,以使页面拉伸。 http://jsfiddle.net/jemqc4tp/

更改container

.jumbotron {
    position:fixed;
    top:0;
    z-index:-1;
    width:100%;
    text-align: center;
    color: #ebebeb;
    background: url("/img/bg.jpg");
}


.container {
    width: 93%;
    margin-top:200px;
    background:white;
}

当然有很多方法可以实现这个结果,这只是一种方式。