2013-04-28 58 views
1

我一直在玩preview of Bootstrap 3,並且遇到了「附加插件」的問題,它允許固定位置浮動條。Bootstrap 3 stickix

請找一個小提琴here顯示我的煩惱。基本上,右側按鈕不會浮動,但是當應用position: fixed時,從網格系統繼承的寬度和偏移樣式似乎消失。

這是我的代碼:

<div class='container'> 
    <div class='row'> 
     <div class='col-span-8'> 
      <legend>Lorem</legend> 
      <div>[Large amounts of text]</div> 
     </div> 
     <div class='col-span-4 well' data-spy='affix' data-offset-top='50'> 
      <div class='btn btn-large btn-danger col-span-12'>This is fixed</div> 
     </div> 
    </div> 
</div> 

我在做什麼錯? (我知道Bootstrap 3仍在積極發展,但我希望有人在這裏有一些見解。)

回答

2

data-offset-top='50'增加了類affix-top。這個類在bootstrap.css中沒有定義。滾動頁面後,類affix替換類affix-topaffix定義固定的位置。這會導致您貼上的div不同的顯示。

也許更改您的代碼到下面顯示的工作更符合預期。注意在這種情況下粘貼的div不顯示在小屏幕上?

<div class='container'> 
    <div class='row'> 
     <div class='col-span-8'> 
      <legend>Lorem</legend> 
      <div>[Large amounts of text]</div> 
     </div> 
     <div class='col-span-4'> 
      <div class="well col-span-4" data-spy='affix'> 
      <div class='btn btn-large btn-danger col-span-12'>This is fixed</div> 
      </div> 
     </div> 
    </div> 
</div> 
+0

能否請您提供一個小提琴,我不能讓您的解決方案工作。 – Randomblue 2013-04-28 20:49:37

+0

請嘗試此操作:http://jsfiddle.net/bassjobsen/2naAU/1/ – 2013-04-28 21:01:19

+0

Bootstrap 3標記自發布後發生了一些變化:新示例 - http://bootply.com/73866 – ZimSystem 2013-08-13 11:14:54