为什么Stellar.js中的元素没有移动?

Mat*_*ood 7 html css jquery html5 css3

我在标题中有3个圆圈,当通过stellar.js滚动时,假设它们以不同的速率下降; 不幸的是,他们甚至不动.他们都有位置属性(绝对); 而且,我已经应用data-stellar-ratio了适当的标签.为什么stellar.js不起作用?更进一步,如何测试jQuery是否只是导航错误?

HTML

<div id="companyInfo" >
    <div class="circlefront" data-stellar-ratio="1.2"></div>
    <div class="circlemiddle" data-stellar-ratio="1.8"></div>
    <div class="circlerear" data-stellar-ratio="3"></div>
    <div class="infoWrapper">
      <h1>Towing, you can't do it without a truck, i have a truck</h1>
      <p>Id abunum ta inte publicae adhui senterem praties tantiena quitas vis, factum destus. Loca vehebus; et? Ti. Upionem, sil tala morbit ina, nique confendum tati et acepsen ihilin sula audactorips, fatur ia consign arisulos inatuis.</p>
    </div>
  </div>
Run Code Online (Sandbox Code Playgroud)

CSS

section#company div#companyInfo {
  height: 24em;
  line-height: 3em;
  margin: 0 auto;
  color: #fff;
}
section#company div#companyInfo div.infoWrapper {
  width: 960px;
  margin: 5em auto;
  text-align: center;
}
section#company div#companyInfo div.infoWrapper h1 {
  font-size: 2em;
}
section#company div#companyInfo div.infoWrapper p {
  line-height: 1.2em;
  font-size: 1.125em;
}
section#company .circlefront {
  background: rgba(255, 255, 255, 0.7);
  width: 500px;
  height: 500px;
  -webkit-border-radius: 50%;
  -moz-border-radius: 50%;
  position: absolute;
  top: 300px;
  left: 400px;
}
section#company .circlemiddle {
  background: rgba(255, 255, 255, 0.5);
  width: 250px;
  height: 250px;
  -webkit-border-radius: 50%;
  -moz-border-radius: 50%;
  position: absolute;
  top: 100px;
  left: 200px;
}
section#company .circlerear {
  background: rgba(255, 255, 255, 0.3);
  width: 100px;
  height: 100px;
  -webkit-border-radius: 50%;
  -moz-border-radius: 50%;
  position: absolute;
  top: 350px;
  right: 100px;
}
Run Code Online (Sandbox Code Playgroud)

jQuery的

<script src="asset/js/libs/jquery.stellar.min.js"></script> 
<script type="text/javascript">

$(function(){
            $.stellar({
                horizontalScrolling: false,
                verticalOffset: 0,
            });
        });
</script>
Run Code Online (Sandbox Code Playgroud)

有关使用stellar.js的资源stellar.js 教程

SVS*_*SVS 4

我刚刚保存了您的网站并使用了您的代码。在我看来一切都很好,但仍然存在一些问题。因此,我删除了所有脚本标签并从 Stellar 演示中添加了 jQuery 和 Stellar,它工作正常。

我只发现一个错误,但我不知道这是这种行为的原因。后面多了一个逗号verticaloffset:0

$(function(){
    $.stellar({
        horizontalScrolling: false,
        verticalOffset: 0, /* Remove this comma at the end */
    });
});
Run Code Online (Sandbox Code Playgroud)

  • 尾随逗号会破坏 IE http://trailingcomma.com/ - linter 会对其发出警告是有原因的 ;)。 (2认同)