css - How do I align these boxes using bootstrap? -


here code:

<div class="row" >                  <div id="box1" class="col-lg-4 box"style="">                     <img src="images/1.png" style="" class="num-img">                     <a href="#" style="text-decoration:none;color:#fff;">box 1 content</a>                 </div>                   <div id="box2" class="col-lg-4 box" style="">                         <img src="images/2.png" style="" class="num-img">                         <a href="#" style="text-decoration:none;color:#fff;">box 2 content</a>                 </div>                 <div id="box3" class="col-lg-4 box" style="">                         <img src="images/3.png" style="" class="num-img">                         <a href="#" style="text-decoration:none;color:#fff;">box 3 content</a>                   </div>              </div> 

css of box:

.box {     height: 130px;     width: 200px;     background-color: #000;     color: #fff;     padding: 20px;     font-size: 30px;     text-align: center; } 

this how want like: enter image description here

this how looks right :

enter image description here

and how looks when remove box class , write:

<div id="box1" class="col-lg-4 "style=""> 

enter image description here

how fix this??

update (after adding margin:0 auto):

enter image description here

you possibly overriding width of col-lg-4 divs, depending on when box css loaded. try

<div id="box1" class="col-lg-4">     <div class="box">         <img src="images/1.png" style="" class="num-img">         <a href="search.jsp" style="text-decoration:none;color:#fff;">box 1 content</a>     </div>   </div>   

this not force col-lg-4 div have set px width, instead % inner div having set width.

if want center blocks within bootstrap cols, add margin: 0 auto; box css.

.box {     height: 130px;     width: 200px;     background-color: #000;     color: #fff;     padding: 20px;     font-size: 30px;     text-align: center;     margin: 0 auto; } 

example using fiddle


Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -