Css div将不会在引导中居中

Css div将不会在引导中居中,css,twitter-bootstrap,Css,Twitter Bootstrap,我正在建立一个引导网站,我在页面的中心有div,我正试图使其居中。我一辈子都想不出来。有人知道为什么它不会居中吗?我试过: margin: 0 auto; text-align: center; 在几乎所有的元素中,我无法让它运行。在这里感到沮丧。这里有一个网站链接,你可以看到我在说什么 下面是代码的一部分,您可以在网站上查看它以了解更多信息: <section class="no-margin" id="main" style="background-image:url(/Gu

我正在建立一个引导网站,我在页面的中心有div,我正试图使其居中。我一辈子都想不出来。有人知道为什么它不会居中吗?我试过:

margin: 0 auto;
text-align: center;
在几乎所有的元素中,我无法让它运行。在这里感到沮丧。这里有一个网站链接,你可以看到我在说什么

下面是代码的一部分,您可以在网站上查看它以了解更多信息:

    <section class="no-margin" id="main" style="background-image:url(/GulflifeRealty.com/images/images/<%=img%>); height:650px; background-size:cover;  background-position:0 -210px; background-repeat:no-repeat;">    
    <div class="container">
        <div class="row">
            <div class="col-lg-12">

            <div>

                <a href="http://matrix.swflamls.com/Matrix/Public/IDXSearch.aspx?count=1&idx=f25b59c&iframe=true&width=100%&height=100%" rel="prettyPhoto[iframes]"><div class="homeBox" style="background-image:url(/GulflifeRealty.com/images/images/<%=listings%>);">

                <h3>See our Listings</h3>


                </div></a>

                <a href="http://matrix.swflamls.com/Matrix/Public/IDXSearch.aspx?count=1&idx=b03d59b&iframe=true&width=100%&height=100%" rel="prettyPhoto[iframes]"><div class="homeBox" style="background-image:url(/GulflifeRealty.com/images/images/<%=mls%>);">
<h3>Search the MLS</h3>

搜索MLS


您无法使用
文本对齐:居中来居中这两个
,因为您正在使用
浮动:左
使它们显示为内联。您需要使用
display:inline block
而不是
float:left
,如下所示:

.homeBox {
     display: inline-block;
     float: none;
}
row > div {
     text-align: center;
}
然后将容器
text align
属性设置为
center
,如下所示:

.homeBox {
     display: inline-block;
     float: none;
}
row > div {
     text-align: center;
}
它可以完美地工作:


哇!!!!!我和CSS之间有这种爱恨关系。谢谢你澄清这一点。当这件事允许我时,我会接受(7分钟)