2017-02-20 32 views
5

我的目標是添加側邊欄,它開始很好地滾動,但當它靠近頁腳時,它開始閃爍。 我做錯了什麼? 看來,引導未定,並保持在#sidebar卷軸上的自舉側邊字綴閃爍

http://codepen.io/anon/pen/MJMQMr

切換.affix-bottom JS

var $sidebar = jQuery('#sidebar'); 

jQuery($sidebar).affix({ 
    offset: { 
    top: $sidebar.offset().top, 
    bottom: function() { 
     return (this.bottom = jQuery('#footer').outerHeight(true)) 
    } 
    } 
}) 

CSS

.affix { 
    top: 0; 
} 

.affix-bottom { 
    position: absolute; 
    top: auto; 
    bottom: 20px; 
} 

HTML

<div class="container"> 

    <div class="header"> 
     <!-- HEADER --> 
    </div> 

    <div class="row"> 
    <div class="content col-md-8"> 
     <!-- CONTENT --> 
    </div> 

    <div class="col-md-4"> 
     <div id="sidebar"> 
     <!-- AFFIXED --> 
     </div> 
    </div> 

    </div> 

    <div id="footer"> 
     <!-- FOOTER --> 
    </div> 

</div> 

回答

0

,如果你需要做的側邊欄粘你爲什麼不這樣做只是這一點:codepen.io

這是你的代碼:

<div class="col-md-4"> 
    <div id="sidebar"> 
    </div> 
</div> 

,這是我的

<div id="sidebar" class="col-md-4"> 
    <div> 
    </div> 
</div> 
+0

你可以添加更多關於你對答案做了什麼的信息嗎? – TehSphinX

+0

我只是把id =「sidebar」放在class =「col-md-4」的div上,查看我編輯它的答案。 –