2012-07-09 57 views
0

我的Bootstrap安裝非常簡單,與example非常相似。我有一個左邊的邊欄和右邊的內容。我打算完成的簡單任務是將頁面的右側居中。在Twitter Bootstrap中居中對齊.span9內容?

更多一般來說,我想集中在div.span9之內的任何div。我用.span4 .offset4,但它不工作:

<!--End of sidebar --> 
<!-- Right side --> 
<div class="span9"> 
    <!-- Right side--> 
    <div class="form-container span4 offset4"> 
     <form class="form-horizontal"> 
      <!-- ... --> 
     </form> 
    </div> 
</div> 
<!--/span--> 

在這裏你可以看到完整的代碼和一個live example on jsFiddle。任何幫助將不勝感激,謝謝。

+0

粗體文字確實無助於可讀性。我不會使用它。 – Blender 2012-07-09 20:19:24

+0

@Blender很抱歉,您的編輯感到厭煩。 – Polmonino 2012-07-09 20:27:13

回答

1

更新:Bootstrap自2.1.0(或其附近)支持流體偏移。請參閱Fluid Offseting doc


流體網格中沒有偏移。檢查這一個:Offset Margin-Left Percentages for Fluid Row in Bootstrap

其次,如果你在.span4溢出一些內容,集中將只適用於.span4容器。您也應該修正內容寬度(即.control-group.control)。

如果你喜歡簡單的方法,你可以保持網格靜態(非流體),並使用.offsetX類或margin-left: auto; margin-right: auto;

+0

Bootstrap現在支持流體網格中的偏移量。參見[Fluid offsetting](http://twitter.github.io/bootstrap/scaffolding.html#fluidGridSystem) – Dhaust 2013-04-15 03:08:05