2015-12-14 144 views
0

我想在引導程序中嵌套的div居中,這也是包裝的內部。嵌套的div居中引導問題

基本上它堅持我的包裝的左側,而不是相對居中本身。

HTML:

<div class="wrapper center-block"> 
<P> 
The panels below need to be centered so they dont stay left. 
They aren't supposed to line up with this paragraph, but be offset so that it looks "fluid"<br /> 
i.e. stop here<br /> 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;v 
</P> 
<div class="row"> 
    <div class="col-lg-8 center-block"> 
     <!-- WHY WONT THIS NESTED DIV CENTER!?--> 
     <div class="panel panel-default"> 
      <div class="panel-heading"> 
       <h3 class="panel-title"><strong>Test panel </strong></h3> 
      </div> 
      <div class="panel-body"> 
       test 
      </div> 
     </div> 
    </div> 
</div> 
<div class="panel-footer col-sm-10 center-block"> 
    <p><small>test footer</small> 
    </p> 
</div> 
</div> 
<!-- /container --> 

CSS:

.wrapper{ 
    max-width:1200px; 
    float: none; 
    margin: 0 auto; 
} 

我在想使另一包裝但這只是似乎過高。有另一種方法嗎?

回答

1

使用Css,你可以使用span來放置文本,它會縮小它。然後,您可以將其與margin-left:auto; margin-right:auto;div(需要一個width)對齊並使其相同。如果是文字,那麼text-align:center;

希望有幫助!

0

按Manuel的建議,我落得這樣做的:

改變

<div class="col-lg-8 center-block"> 

<div class="wrapper2 center-block"> 

新增CSS

.wrapper2{ 
    max-width:600px; 
    float: none; 
    margin: 0 auto; 
} 

或者

<div class="center-block" style="max-width:600px;"> 

作品一樣。