Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Single full-width column in row with twitter bootstrap grid

When using bootstrap's grid, what is the best way to markup a single full-width column in a row?

Do you have to use container and row to hold the column (.container > .row > .col-xs-12 > .actual-content), or can you get rid of the row and column altogether and simply use a wrapping container (.container > .actual-content)?

Let's say

<div class="container">
  <div class="row">
    <!-- multiple columns -->
  </div>

  <div class="row">
    <div class="col-xs-12">
      <p>Actual content goes here. It will span the entire width.</p>
    </div>
  </div>

  <div class="row">
    <!-- multiple columns -->
  </div>
</div>

vs

<div class="container">
  <div class="row">
    <!-- multiple columns -->
  </div>

  <p>Actual content goes here. It will span the full width.</p>

  <div class="row">
    <!-- multiple columns -->
  </div>
</div>

Is one approach considered superior over the other? Since the column spans the entire width for all media sizes, I don't need any responsive features. Rendered output should be the same, but maybe there are subtle differences which I'm not aware of. Using container, row, and column seems like overkill …

like image 989
knittl Avatar asked Oct 04 '14 12:10

knittl


People also ask

How do I center a column in a row in Bootstrap?

The first approach uses bootstrap offset class. The key is to set an offset equal to half of the remaining size of the row. So for example, a column of size 2 would be centered by adding an offset of 5, that's (12-2)/2.

How do I make Bootstrap columns equal width?

In Bootstrap 5, there is an easy way to create equal width columns for all devices: just use the . col class on a specified number of col elements. Bootstrap will recognize how many columns there are, and each column will get the same width.

Which layout in Bootstrap will provide 100% width?

Containers are the most basic layout element in Bootstrap and are required when using our default grid system. Choose from a responsive, fixed-width container (meaning its max-width changes at each breakpoint) or fluid-width (meaning it's 100% wide all the time).

Can you have a row in a column Bootstrap?

You can easily nest grids using bootstrap by adding additional rows. Here is a step-by-step guide for this process. Within the desired column, create another element with class row . This second row element will contain your nested grid.


1 Answers

The one without the row/grid according to Bootstrap's own documentation. It is the correct way -- don't wrap it with more classes, that's more markup for NO reason.

I posted about this a couple days ago: col-*-12 (col-xs / col-sm / etc) use in Bootstrap 3

Documentation:

enter image description here

No grid classes are necessary for full-width elements.

This is the correct way:

<div class="container">
  <div class="row">
    <!-- multiple columns -->
  </div><!-- closing .row -->

  <p>Actual content goes here. It will span the full width.</p>

  <div class="row">
    <!-- multiple columns -->
  </div><!-- closing .row -->
</div><!-- closing .container -->
like image 86
Christina Avatar answered Oct 24 '22 14:10

Christina