2014-10-08 94 views
-1

我想將容器中div的所有內容居中。 我試圖使用保證金0汽車,它沒有工作 我怎麼能中心呢?如何居中div

<div class="container"> 
    <div class="text-center" style="margin:0 auto;overflow:auto;"> 
     <div style="float:left;width:15%;margin-right:2px;"> 

      <img src="PICTURES/Bruce-Crocker_311x312(2).jpg" class="img-responsive" /> 
      <div class="contenthover"> 
       <p>bla</p> 
      </div> 
     </div> 
     <div style="float:left;width:15%;margin-right:2px;"> 

      <img src="PICTURES/Bruce-Crocker_311x312(2).jpg" class="img-responsive" /> 
      <div class="contenthover"> 
       <p>bla</p> 
      </div> 
     </div> 


    </div> 

任何人都可以幫忙嗎?

回答

1

用bootstrap center-block類上要居中,使用text-center文本任何塊元素..

<div class="container"> 
    <div> 
      <img src="PICTURES/Bruce-Crocker_311x312(2).jpg" class="center-block img-responsive"> 
      <div class="text-center"> 
       <p>bla</p> 
      </div> 
    </div> 
</div> 

http://www.bootply.com/65YSFBl6mF

+0

謝謝你,只是如果你想添加,如果一個DIV它的好你用float添加更多的div:離開它不起作用。 – matishw 2014-10-08 23:13:05