如何使用'spanX'类来定位Bootstrap div? [英] How do I center a Bootstrap div with a 'spanX' class?

查看:64
本文介绍了如何使用'spanX'类来定位Bootstrap div?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用引导程序,并尝试将一个div(span7)置于中心位置:

 < div class = -fluid> 
< div id =mainclass =span7>
Lorem ipsum dolor sit amet
< / div>
< / div>

我的CSS代码是:

  #main {
margin:0px auto;
}

但它未设置在中心。如何设置中心?

解决方案

Twitter的引导 .span 漂浮在左边,所以他们不会通过通常的手段居中。所以,如果你想让它 span 的中心只需添加 float:none 到你的



 >  #main {
margin:0 auto;
float:none;
}


I use bootstrap and am trying to center a div(span7) like that:

<div class="row-fluid">
    <div id="main" class="span7">
        Lorem ipsum dolor sit amet
    </div>
</div>

my css code is:

#main{
    margin:0px auto;
}

But it isn't set at the center. How can i set center?

解决方案

Twitter's bootstrap .span classes are floated to the left so they won't center by usual means. So, if you want it to center your span simply add float:none to your #main rule.

CSS

#main {
 margin:0 auto;
 float:none;
}

这篇关于如何使用'spanX'类来定位Bootstrap div?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆