簡體   English   中英

$ location.hash和$ anchorScroll()的偏移量

[英]offset for $location.hash and $anchorScroll()

我根據id進行錨定滾動-這樣-

function ($scope, $location, $anchorScroll) {
      $scope.gotoBottom = function() {
        // set the location.hash to the id of
        // the element you wish to scroll to.
        $location.hash('bottom');

        // call $anchorScroll()
        $anchorScroll();
      };

(摘自angularjs.org)

由於固定的標頭,我必須為此$location.hash('bottom')設置一個偏移量(常見的問題是將html錨點偏移以調整為固定的標頭 )。

如何獲得補償?

試試這個

$ anchorScroll.yOffset = 20;

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM