2014-04-19 40 views

回答

1

1. 如果即使Demo代碼不起作用,請檢查您是否正確提供了jquery或stellar.js路徑。 如果您有任何錯誤,您可以在瀏覽器控制檯中檢查它。如果無法加載資源,控制檯將打印它。

2. 如果路徑正確,檢查是否運行恆星的初始化,載入頁面時,或者如果您爲正確的元素提供了「data-stellar-background-ratio」屬性。如果您將數據恆星背景比設置爲0,則它​​不會滾動。 請注意,它也不適用於移動設備。

3. 如果您檢查了上述所有內容,但它仍然無效,請嘗試在元素末尾插入腳本。有時它有幫助。 事情是這樣的:

<html> 
    <head> 
    <!-- Title, CSS, and other stuff --> 
    </head> 
    <body> 
    <!-- Content here with right stellar attributes -- > 
    ... 

    <!-- At the end of body load the scripts, and run initialisation --> 
     <script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script> 
     <script src="YOUR_PATH_TO_STELLAR/jquery.stellar.min.js" type="text/javascript"></script> 

     <script type="text/javascript"> 
     $(window).stellar({ 
     scrollProperty: 'scroll', 
     horizontalScrolling: false, 
     positionProperty: 'position' 
     }); 
     </script> 

    </body> 
    </html> 
+0

可能是第三點。所有工作歡呼! – user3525989

0

我有一個情況我stellar.js視差滾動將無法使用,直到我的瀏覽器窗口大小被調整。我發現$.stellar('refresh');似乎解決了這個問題。 (使用AngularJS)

angular.module('ForeverLeather').controller('HomeCtrl', ['$scope', function($scope) { 

    $(window).stellar({ 
    horizontalScrolling: false, 
    verticalOffset: 0, 
    horizontalOffset: 0, 
    responsive: true, 
    }).stellar('refresh'); 

}]);