2016-05-08 14 views
1

Ich möchte das Rastersystem zentrieren, aber es wird nicht, ich dachte, vielleicht hat es etwas mit der Grenze meiner Bilder zu tun ?. hier angeschossen der Bildschirm what it is right now what i want it to beWie wird das Rastersystem horizontal zentriert?

HTML:

<div class=" container"> 
    <div class="row"> 
     <div class="col-md-4"> 
      <div class="optionBorder"> 
       <img src="images/page-1.svg" height="74px" width="50px"> 
      </div> 
     </div> 
     <div class="col-md-4"> 
      <div class="optionBorder"> 
       <img src="images/page-1.svg" height="74px" width="50px"> 
      </div> 
     </div> 
     <div class="col-md-4"> 
      <div class="optionBorder"> 
       <img src="images/page-1.svg" height="74px" width="50px"> 
      </div> 
     </div> 
    </div> 
</div> 

CSS:

.optionBorder 
{ 
    border: 1px solid #f5f5f5; 
    height: 130px; 
    width: 130px; 
    line-height: 130px; 
    text-align: center; 
} 

Antwort

2

vor Zeile ein weiteres Element Nehmen Sie mit etwas Breite und sie

zum Beispiel Zentrum zu machen.

HTML

<div class="test"> 
    <div class="row"> 
    <div class="col-md-4"> 
     <div class="optionBorder"> 
     <img src="http://placehold.it/350x150" height="74px" width="50px"> 
     </div> 
    </div> 
    <div class="col-md-4"> 
     <div class="optionBorder"> 
     <img src="http://placehold.it/350x150" height="74px" width="50px"> 
     </div> 
    </div> 
    <div class="col-md-4"> 
     <div class="optionBorder"> 
     <img src="http://placehold.it/350x150" height="74px" width="50px"> 
     </div> 
    </div> 
    </div> 
</div> 

CSS

.test { 
    width: 450px; 
    margin: auto; 
    margin-bottom: 15px; 
} 

bootply

1
<style> 
.paraentCont{ 
width:100%; 
max-width:300px; 
margin:auto; 
    } 
</style>  

<div class=" container"> 
    <div class="paraentCont"> 
<div class="row"> 
    <div class="col-md-4"> 
     <div class="optionBorder"> 
      <img src="images/page-1.svg" height="74px" width="50px"> 
     </div> 
    </div> 
    <div class="col-md-4"> 
     <div class="optionBorder"> 
      <img src="images/page-1.svg" height="74px" width="50px"> 
     </div> 
    </div> 
    <div class="col-md-4"> 
     <div class="optionBorder"> 
      <img src="images/page-1.svg" height="74px" width="50px"> 
     </div> 
    </div> 
</div> 

+1

Möglicherweise wird Ihr Code stören, weil Container 1170px Breite haben –

+0

@IsmailFarooq Thx bro das ist mein schlechtes – Noni

0

hier Eigentlich gibt es richtigen Weg zu gehen, während Bootsrap mit

  1. der vordefinieren Klasse verwendet text-center
  2. Verwenden Sie q Bootstrap Helfer wie .inline-block{display: inline-block}

.inline-block{display: inline-block}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/> 
 
<div class=" container"> 
 
    <div class="row text-center"> 
 
     <div class="col-md-4 inline-block"> 
 
      <div class="optionBorder"> 
 
       <img src="images/page-1.svg" height="74px" width="50px"> 
 
      </div> 
 
     </div> 
 
     <div class="col-md-4 inline-block"> 
 
      <div class="optionBorder"> 
 
       <img src="images/page-1.svg" height="74px" width="50px"> 
 
      </div> 
 
     </div> 
 
     <div class="col-md-4 inline-block"> 
 
      <div class="optionBorder"> 
 
       <img src="images/page-1.svg" height="74px" width="50px"> 
 
      </div> 
 
     </div> 
 
    </div> 
 
</div>

+0

Testen Sie Ihren eigenen Code zuerst dann post –

Verwandte Themen