Twitter’s Bootstrap 3 RC2 (important changes)

The release candidate 2 of Twitter’s Bootstrap 3 shows some important changes. I decide to write a separate blog for it. Before start reading read first to get an idea of the changes between Twitter’s Bootstrap 3 and Twitter’s Bootstrap 2.

Grid

RC2 shows new grid class prefixes: col-xs-* for mobile devices follow by col-sm-* (tablet), col-md-* (laptop) and col-lg-* (desktop). The grid is fluid by default still. Gutter between the columns are replaced with a padding on both sides of the row. See the table below for a total view:

Twitter's Bootstrap Grid
Twitter’s Bootstrap Grid

I will show you an example of the use of the grid. Consider this example html:


<div class="container">
<div class="row">
<div class="col-xs-6" style="background-color: pink;">Pink</div>
<div class="col-xs-6" style="background-color: purple;">Purple</div>
</div>
<div class="row">
<div class="col-sm-6" style="background-color: pink;">Pink</div>
<div class="col-sm-6" style="background-color: purple;">Purple</div>
</div>
<div class="row">
<div class="col-sm-6 col-md-4" style="background-color: pink;">Pink</div>
<div class="col-sm-6 col-md-8" style="background-color: purple;">Purple</div>
</div>
<div class="row">
<div class="col-sm-6 col-md-4 col-lg-2" style="background-color: pink;">Pink</div>
<div class="col-sm-6 col-md-8 col-lg-10" style="background-color: purple;">Purple</div>
</div>
</div>

On large desktops (screenwidth >=1200px) this will look like:

1200

Note the `col-lg-10` are applied on the fourth row.

Laptops >= 992px will look like (grid-md-* will be applied on the third and fourth row):

980

Tabets >= 768px:

768 On the first row col-xs-6 has been applied. The next three rows are split with col-sm-6.

<768px:

extra small grid for mobile phones

All rows stack except from the first. The first row got col-xs- for the extra small grid which never stack.

So the col-xs-* will never stack as you see. col-xs-* will always be applied (make the grid horizontal) while the other classes are applied above their breakpoint. Also see the difference between col-xs-* and col-sm-* in the mobile view. Beside the break-points all grids have a max-container size too. To build your templates you could use this default grid, but variations between breakpoints are possible also.

The Jamedo’s Bootstrap Start Theme use a max-container size of 1200 pixels in combination with the Small grid by default. To build a non responsive site TB advice too use the Extra Small Grid with a fixed contianer size, see http://getbootstrap.com/getting-started/#disable-responsive. Read more about non responsive sites with TB3: .

Also realize there is no breakpoint at 480px at the moment. This breakpoint can be used for different views for phones landscape and portrait. See also: Missing the col-ts-* (tiny to small) set of classes?

Althought the gutters are replaced with padding the Less files and the current version of the customizer still define a @grid-gutter-width. This value is used to calculate inner padding of the columns which is @grid-gutter-width/2 = 15 pixels on each side. The margins on the left and the right side of the grid are filled with a negative margin of @grid-gutter-width/2 px too.

Classes for offsets, pull and push are availiable for all grids except the Extra Small grid. The classes have names like .col-sm-offset-* and .col-lg-pull-*.

Other changes in RC2

Glyphicons are back. Twitter’s Bootstrap 3 includes 180 glyphs in font format from the Glyphicon Halflings set. Free of cost and so they ask for a backlink to Glyphicons.com.

Stucture of the navbar has been changed a little. TB3 provide four types of navbars: The default navbar, Static top navbar and fixed navbar top and bottom. See the examples on the Get started page.

Try to check the migration section in the docs to explorer the complete set of changes.

Twitter’s Bootstrap 3 also pays attention to accessibility. They intoduce a new class `sr-only` only visible for screen readers (See: http://a11yproject.com/posts/how-to-hide-content/). You can use it to build links to the main content on the top of your document of navbar like:

<body>
  <a href="#content" class="sr-only">Skip to content</a>
  <div class="container" id="content">
    The main page content.
  </div>
</body>

They also ask your attention for the logical structure of your header elements (<h1> ... <h6>). Default Bootstrap font sizes help you to make your visual (formatted) style consistent with the semantic structure. Screen readers use this semantic stucture to build a table of contents of your document. Consider to not change the font sizes by css but choose the subordinate heading element which fits the semantic structure too. See also: Headings and Subheadings.

New elements elements make it possible to construct b.e. a Listgroup with badges:

Listgroup with badges

Last but not least provides RC2 an example of a Bootstrap Theme constructed in Less: http://getbootstrap.com/examples/theme/

It’s a shame! The newest version of Github’s most popular project is not backward compatible

Yes, i’m talking about Twitter’s Bootstrap. Release Candidate 2 of version 3 of Bootstrap 3 has been released today. And we will find at least class name changes again, see: What is wrong with Bootstrap 3 RC2. Is there a reason to be not backward compatible? No. Or maybe…. you will need some extra CSS code which could slow down your site. Unless you didn’t use the responsive features of version 2.x. Twitter’s Bootstrap 3 can’t be used without the responsive code any more.
The real reason to be not backwards compatible will be the new mobile first approach, i think. To adopt this approach you will have to change the structure of your CSS loading. You will have to work from small to big. I wonder what the benefits of the mobile first approach are nowadays. I understand some older smart phones don’t handle all css3 features or not even Javascript. Of course it would be nice when all this old phone users will see a nice looking and well functioning website.
But who has such old phone and why? Most people buy the newest phone every week. Maybe not every week but certainly often.
I also bet most web designers never check their site on a ‘old’ phone. They will load the site on their newest i-Phone via broadband wifi and say: Wooh that looks cool.
Maybe this the problem with Twitter’s Bootstrap too. It’s cool.
Should we rename everything? Why not? Everybody will happy with this new stuff, they don’t care.

If the mobile first approach really reduce load time / data traffic mobile users will profit a little. But Mobile Internet will become faster and faster and this happens sooner and sooner.

Should you migrate your website from Twitter’s Bootstrap 2.x to 3?

I don’t think so. With Twitter’s Bootstrap you already have chosen a progressive technology. Your website will be responsive and fit mobile users needs too. New browsers and techniques won’t work with 2.x in future. But also consider the mean life time of a / your web design. Twitter’s Bootstrap drops support for IE7 and FF3 (check the facts here: IE10 blows past IE7 and IE6′s combined market share, Firefox gains too, but Chrome hits 21-month low ). Beside browser support the typehead plugin is also dropped.

Should you build your new website with Twitter’s Bootstrap 3?

You could consider it at least (after the final release). Read also: Writing Twitter’s Bootstrap with upgrading to v3 in mind. If you used 2.x before you should learn some new things.
Except from the backwards compatible their seems nothing wrong with the new 3 version. The new small grid will make happy the modern phone users. The grid is fluid by default now, so you will have to study the profits and disadvantages of this when you used to the fixed layout.

What are the alternatives? Personal i love the idea behind (css) frameworks with a grid. I should never consider to write all the media queries, browser compatible css. etc. myself again. Zurb’s Foundation can be an alternative. (Is Bootstrap 3 RC 1 ready for production?).

New techniques / insights decouple CSS from HTML. This will make future migrations less painful maybe. So also read this post: Migrating from Zurb Foundation / Twitter Bootstrap to Bourbon & Neat. It refers to Bourdon and Neat. As they say: “it relies entirely on Sass mixins and does not pollute your HTML”. This combination looks promising too.

Migrate your (former) Skematik theme framework to Twitter’s Bootstrap 3: Instructions for theme developers

At Jamedo Websites we work with the Skematik Theme(work) to build responsive websites. Unfortunately the website was down for a while and Skematik use Twitters Bootstrap 2 only. Cause we need a new version of Skematik i start to migrate it to TB3. You will find this new version on: https://github.com/bassjobsen/jamedo-bootstrap-start-theme.

To use the theme work to build your own child theme use the instruction below:

  1. download from: https://github.com/bassjobsen/jamedo-bootstrap-start-theme/archive/master.zip
  2. copy the content of this .zip to the folder skematik in the wp-content/themes folder (the zip file creates the folder “https://github.com/bassjobsen/jamedo-bootstrap-start-theme/archive/master.zip” you have to rename this to “skematik” )
  3. (search and) replace all “span*” classes in your theme files with “col-lg-*”, see also: http://stackoverflow.com/a/17890898/1596547
  4.  fix all other points (general issues should be send by email to bass@w3masters.nl or send as a pull request to https://github.com/bassjobsen/jamedo-bootstrap-start-theme )

Basic setup for your child themes:

Read: http://codex.wordpress.org/Child_Themes#How_to_Create_a_Child_Theme. So basically create style.css in your child theme folder. Start this file with: @import url("../skematik/style.css");

Learn more about Bootstrap 3

Bootstrap 3 don’t have a separate responsive CSS file any more.

From now Twitter’s Bootstrap defines three grids: Tiny grid for Phones (<480px), Small grid for Tablets (<768px) and the Medium-large grid for Desktops (>768px). The row class prefixes for these grid are “.col-”, “.col-sm-” and “.col-lg-”. The Medium-large grid will stack below 768 pixels screen width. So does the Small grid below 480 pixels and the tiny grid never stacks.

For this reason the “span*” classes in your theme files are replaced with “col-lg-*” in step 3 above. With “col-lg-*” the grid become horizontal above a screen width of 992px (desktop). Below this screen width elements will stack. To start the stacking at 767px use the “col-sm-*” prefixes instead of “.col-lg-”. Read Twitter Bootstrap 3 breakpoints and grid for more information.

Read Bootstrap your (designer’s) mind  also and ask your designer to deliver different designs for screen widths (from low to high). This will help you to choose the right grid settings.

For other changes read: Migrate your templates from Twitter Bootstrap 2.x to Twitter Bootstrap 3 and http://bootply.com/bootstrap-3-migration-guide.

You will find the official documentation of Twitter’s Bootstrap 3 now on: http://getbootstrap.com/.