2015-12-14 66 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;"> 

作品一样。