html5 - Bootstrap - need of "col-sm-12"? -


simple question - <div class="col-sm-12"> needed?

example 1:

<div class="row">     <h1>title</h1>     <div class="col-sm-6">         half     </div>     <div class="col-sm-6">         half     </div> </div> 

example 2:

<div class="row">     <div class="col-sm-12">         <h1>title</h1>     </div>     <div class="col-sm-6">         half     </div>     <div class="col-sm-6">         half     </div> </div> 

what better , why? thank you.

all bootstrap grids works second example. .row element have negative margin compensate positive padding in .col-* elements. it´s better , more logical second example.

in first example, haven't got paddings of .col-* elements , negative margin produce unexpected results.

example col-sm-12:

<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1q8mtjoasx8j1au+a5wdvnpi2lkffwweaa8hdddjzlplegxhjvme1fgjwpgmkzs7" crossorigin="anonymous">  <script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0msbjdehialfmubbqp6a4qrprq5ovfw37prr3j5elqxss1yvqotnepnhvp9aj7xs" crossorigin="anonymous"></script>  <div class="row">      <div class="col-sm-12">          <h1>title</h1>      </div>      <div class="col-sm-6">          half      </div>      <div class="col-sm-6">          half      </div>  </div>

example without col-sm-12:

<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1q8mtjoasx8j1au+a5wdvnpi2lkffwweaa8hdddjzlplegxhjvme1fgjwpgmkzs7" crossorigin="anonymous">  <script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0msbjdehialfmubbqp6a4qrprq5ovfw37prr3j5elqxss1yvqotnepnhvp9aj7xs" crossorigin="anonymous"></script>  <div class="row">      <h1>title</h1>      <div class="col-md-6">          half      </div>      <div class="col-md-6">          half      </div>  </div>

as can see, in second example you'll obtain negative margin in <h1> element. that's why must use columns rows.


Comments

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -