简体   繁体   English

使用Stellar.js的视差效果

[英]Parallax effects with Stellar.js

I'm working on a website and I want to implement some slight parallax effects. 我正在一个网站上,我想实现一些轻微的视差效果。

Here is my site so far: 到目前为止,这是我的网站:

http://claytonkinder.com/ http://claytonkinder.com/

I want the parallax to affect the gray field background image so that it scrolls at a different rate, but I can't configure it to work. 我希望视差影响灰度场背景图像,以便其以不同的速率滚动,但是我无法将其配置为正常工作。

Here is my html: 这是我的html:

<div id="top-block" data-stellar-background-ratio="0.5">
    <div class="bg-title">
        <h1 id="site-title">MODERN</h1>
    </div>
        <h2 id="site-subtitle">A splash of color</h2>

    <a href="#">
        <div class="top-block-button button1">Watch Video</div>
    </a>
    <a href="#">
        <div class="top-block-button button2">Download</div>
    </a>    
</div>

Here is my CSS: 这是我的CSS:

#top-block {
   background-image: url('../../img/block.jpg');
   background-repeat: no-repeat;
   background-size: cover;
   text-align: center;
   padding-top: 200px;
   padding-bottom: 200px;
}

And here is my jQuery: 这是我的jQuery:

$(function(){
   $.stellar();
});

I can't figure out where I went wrong according to the Stellar.js documents. 根据Stellar.js文档,我无法弄清楚哪里出了问题。

When I put your code in JS Fiddle it works: http://jsfiddle.net/a32qeyz1/ 当我将您的代码放在JS Fiddle中时,它会起作用: http : //jsfiddle.net/a32qeyz1/

Looks like your call to stellar.js is causing a 404 看来您对stellar.js的呼叫导致404错误

<script src="js/stellar.min.js"></script>

Might want to double check your file path. 可能要仔细检查您的文件路径。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM