Requires HTML5 doctype

Bootstrap makes use of HTML elements and CSS properties that require the use of the HTML5 doctype. Be sure to include it at the beginning of every Bootstrapped page in your project.

<!DOCTYPE html>
<html lang="en">
  ...
</html>
        

Typography and links

Within the scaffolding.less file, we set basic global display, typography, and link styles. Specifically, we:

  • Remove margin on the body
  • Set background-color: white; on the body
  • Use the @baseFontFamily, @baseFontSize, and @baseLineHeight attributes as our typographyic base
  • Set the global link color via @linkColor and apply link underlines only on :hover

Reset via Normalize

As of Bootstrap 2, the traditional CSS reset has evolved to make use of elements from Normalize.css, a project by Nicolas Gallagher that also powers the HTML5 Boilerplate.

The new reset can still be found in reset.less, but with many elements removed for brevity and accuracy.

1
1
1
1
1
1
1
1
1
1
1
1
4
4
4
4
8
6
6
12

The default grid system provided in Bootstrap utilizes 12 columns that render out at widths of 724px, 940px (default without responsive CSS included), and 1170px. Below 767px viewports, the columns become fluid and stack vertically.

<div class="row">
  <div class="span4">...</div>
  <div class="span8">...</div>
</div>
   

As shown here, a basic layout can be created with two "columns", each spanning a number of the 12 foundational columns we defined as part of our grid system.

Offsetting columns

4
4 offset 4
3 offset 3
3 offset 3
8 offset 4
       <div class="row">
       <div class="span4">...</div>
       <div class="span4 offset4">...</div>
       </div>
    

Nesting columns

With the static (non-fluid) grid system in Bootstrap, nesting is easy. To nest your content, just add a new .row and set of .span* columns within an existing .span* column.

Example

Nested rows should include a set of columns that add up to the number of columns of it's parent. For example, two nested .span3 columns should be placed within a .span6.

Level 1 of column
Level 2
Level 2
       <div class="row">
        <div class="span12">
         Level 1 of column
         <div class="row">
          <div class="span6">Level 2</div>
          <div class="span6">Level 2</div>
         </div>
        </div>
       </div>
     

Fluid columns

1
1
1
1
1
1
1
1
1
1
1
1
4
4
4
4
8
6
6
12

Percents, not pixels

The fluid grid system uses percents for column widths instead of fixed pixels. It also has the same responsive variations as our fixed grid system, ensuring proper proportions for key screen resolutions and devices.

Fluid rows

Make any row fluid simply by changing .row to .row-fluid. The columns stay the exact same, making it super straightforward to flip between fixed and fluid layouts.

Markup

<div class="row-fluid">
  <div class="span4">...</div>
  <div class="span8">...</div>
</div>

Fluid nesting

Nesting with fluid grids is a bit different: the number of nested columns doesn't need to match the parent. Instead, your columns are reset at each level because each row takes up 100% of the parent column.

Fluid 12
Fluid 6
Fluid 6
        <div class="row-fluid">
          <div class="span12">
            Level 1 of column
             <div class="row-fluid">
              <div class="span6">Level 2</div>
              <div class="span6">Level 2</div>
             </div>
          </div>
         </div>
     
Variable Default value Description
@gridColumns 12 Number of columns
@gridColumnWidth 60px Width of each column
@gridGutterWidth 20px Negative space between columns

Variables in LESS

Built into Bootstrap are a handful of variables for customizing the default 940px grid system, documented above. All variables for the grid are stored in variables.less.

How to customize

Modifying the grid means changing the three @grid* variables and recompiling Bootstrap. Change the grid variables in variables.less and use one of the four ways documented to recompile. If you're adding more columns, be sure to add the CSS for those in grid.less.

Staying responsive

Customization of the grid only works at the default level, the 940px grid. To maintain the responsive aspects of Bootstrap, you'll also have to customize the grids in responsive.less.

Fixed layout

The default and simple 940px-wide, centered layout for just about any website or page provided by a single <div class="container">.

<body>
  <div class="container">
    ...
  </div>
</body>

Fluid layout

<div class="container-fluid"> gives flexible page structure, min- and max-widths, and a left-hand sidebar. It's great for apps and docs.

<div class="container-fluid">
  <div class="row-fluid">
    <div class="span2">
      <!--Sidebar content-->
    </div>
    <div class="span10">
      <!--Body content-->
    </div>
  </div>
</div>

Responsive devices

What they do

Media queries allow for custom CSS based on a number of conditions—ratios, widths, display type, etc—but usually focuses around min-width and max-width.

  • Modify the width of column in our grid
  • Stack elements instead of float wherever necessary
  • Resize headings and text to be more appropriate for devices

Use media queries responsibly and only as a start to your mobile audiences. For larger projects, do consider dedicated code bases and not layers of media queries.

Supported devices

Bootstrap supports a handful of media queries in a single file to help make your projects more appropriate on different devices and screen resolutions. Here's what's included:

Label Layout width Column width Gutter width
Smartphones 480px and below Fluid columns, no fixed widths
Smartphones to tablets 767px and below Fluid columns, no fixed widths
Portrait tablets 768px and above 42px 20px
Default 980px and up 60px 20px
Large display 1200px and up 70px 30px

Requires meta tag

To ensure devices display responsive pages properly, include the viewport meta tag.

         <meta name="viewport" content="width=device-width, initial-scale=1.0">
       

Using the media queries

Bootstrap doesn't automatically include these media queries, but understanding and adding them is very easy and requires minimal setup. You have a few options for including the responsive features of Bootstrap:

  1. Use the compiled responsive version, bootstrap-responsive.css
  2. Add @import "responsive.less" and recompile Bootstrap
  3. Modify and recompile responsive.less as a separate file

Why not just include it? Truth be told, not everything needs to be responsive. Instead of encouraging developers to remove this feature, we figure it best to enable it.

       // Landscape phones and down
       @media (max-width: 480px) { ... }

       // Landscape phone to portrait tablet
       @media (max-width: 767px) { ... }

       // Portrait tablet to landscape and desktop
       @media (min-width: 768px) and (max-width: 979px) { ... }

       // Large desktop
       @media (min-width: 1200px) { ... }
      

Responsive utility classes

What are they

For faster mobile-friendly development, use these basic utility classes for showing and hiding content by device.

When to use

Use on a limited basis and avoid creating entirely different versions of the same site. Instead, use them to complement each device's presentation.

For example, you might show a <select> element for nav on mobile layouts, but not on tablets or desktops.

Support classes

Shown here is a table of the classes we support and their effect on a given media query layout (labeled by device). They can be found in responsive.less.

Class Phones 480px and below Tablets 767px and below Desktops 768px and above
.visible-phone Visible
.visible-tablet Visible
.visible-desktop Visible
.hidden-phone Visible Visible
.hidden-tablet Visible Visible
.hidden-desktop Visible Visible

Test case

Resize your browser or load on different devices to test the above classes.

Visible on...

Green checkmarks indicate that class is visible in your current viewport.

  • Phone✔ Phone
  • Tablet✔ Tablet
  • Desktop✔ Desktop

Hidden on...

Here, green checkmarks indicate that class is hidden in your current viewport.

  • Phone✔ Phone
  • Tablet✔ Tablet
  • Desktop✔ Desktop

Module Positions

This template is divided into 16 distinct rows with a variety of primary functions and different sub-divisions.

Row Name Primary function Sub divisions
0 nav-top Menu fixed to the top of the screen none
1 nav-r1 Menu at the top of the page, but not fixed. none
2 section-r2 Header: Logo, Modules or other content 4 section-r2-1 to section-r2-4
3 nav-r3 Menu none
4 section-r4 Module none
5 nav-r5 Menu none
6 section-r6 Modules or other content 4 section-r6-1 to section-r6-4
7 section-r7 Modules or other content 4 section-r7-1 to section-r7-4
8 nav-r8 Menu none
9 section-main Main content from Joomla Articles 3 section-main-left, section-main, section-main-right
10 section-r10 Modules or other content 4 section-r10-1 to section-r10-4
11 section-r11 Modules or other content 4 section-r11-1 to section-r11-4
12 section-r12 Module or other content none
13 section-r13 Footer: Modules or other content 4 section-r13-1 to section-r13-4
14 nav-r14 Menu at the bottom of the page, but not fixed. none
15 nav-bottom Menu fixed to the bottom of the screen none

Layout diagram

This is a simple way to visualise the module positions and rows.

template layout

The primary function represents the default style of that row.

A menu row has the class="subnav", except for the 2 fixed positions where class="navbar navbar-fixed-top" and class="navbar navbar-fixed-bottom".

The section-r2 row is defined in the template as the HTML5 element <header>, while section-r13 is defined as the HTML5 element <footer>.

While these are pre-defined, it does not stop you using any position for any purpose, these are simply the most common uses. However, if you use a menu row for a module it will have the .subnav class style applied to it.


Content First

Collapsed content

In keeping with our "content first" and "one web" philosophy, all content sections on screens 768px wide and below are collapsed. This means that the first thing the user will is the main content, below the menu(s) and some "show content" buttons.

This way we ensure that everyone recieves the same information, but smaller screens are not swamped by the information displayed above the articles - scrolling down, down, down to get to the parts they came to read.

Pressing the "show" button reveals the content for that ROW, so if you have 4 span12 modules on the row all 4 will be collapsed and shown at the same time. If you want to collapse individual module positions you can do that using by adding the relevant code to a "Custom HTML" module, and embedding another module within it.

Button text

The buttons for showing and hiding content are labelled by default with their row name (eg "row4 content", except for section-row2 and section-row13 where they are labelled "header content" and "footer content" respectively.

In the Tempate Administration you can edit the defaults to give a meaningfull name to the button, eg. "Banners"

When a row has been collapsed the button text is prepended with "Show " and when a collapsible row is visiible the button text is prepended with "Hide ". You can change the prepending text in the file kwd-j-bootstrap.css

.heading_hide:before {
    content: 'Hide ';
}

.heading_show:before {
    content: 'Show ';
}
      


Collapsed View

This is what a visitor with a small screen will see when arriving at this website.

collapsed view of the homepage

The buttons use the bootstrap javascript "collapse" plugin

It provides a nice accordion style show and hide effect.

This is the same jasvascript used for the fixed menu show and hide.

Defining spans

Using spans for modules

In the template adminstration, for rows with more than 1 module position, you can select the number of columns each module position spans.
Menu rows, and rows with only 1 position in them, are set to span 100% of the available width.

Adding a <space>span<number> to the module class in the module manager allows further span positioning.

For example if you set section-r6-1 in the template manager to span 9 columns, then when assigning a module to that position you can add offset3 span6 to fine tune the location of the module.

If you assign a "Custom HTML" module to a position you can use any of the twitter bootstrap CSS classes, HTML and javascript.

You can force any span to have no left margin using the options in the template manager, or by adding class="noLeftMargin" to your custom code.

The footer of this page is module position section-r13-1 with a custom HTML module assigned to it. Check out the code used

Important note

Using a leading space when adding a custom module class is essential.

Using spans for content

You can add spans into Joomla! articles to customise the output. This section you are reading now is a Joomla! article and uses that technique.

If you not familiar with how to add HTML to an article you should read the Joomla! documentation on editors and Article management.



Footer code

<hr class="soften" />
<div class="row-fluid">
<div class="span6">
<p>Designed and built with all the love in the world <a href="http://twitter.com/twitter" target="_blank">@twitter</a> by <a href="http://twitter.com/mdo" target="_blank">@mdo</a> and <a href="http://twitter.com/fat" target="_blank">@fat</a>.</p>
<p>Code licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0" target="_blank">Apache License v2.0v/a>.
Documentation licensed under <a href="http://creativecommons.org/licenses/by/3.0/">CC BY 3.0</a>.</p>
<p>Icons from <a href="http://glyphicons.com">Glyphicons Free</a>, licensed under <a href="http://creativecommons.org/licenses/by/3.0/">CC BY 3.0</a>.</p>
</div>
<div class="span6">
<p class="pull-right"><a href="#">Back to top</a>
</p> <p>Joomla! CMS © 2005 - 2012 Open Source Matters, Inc. All rights reserved.</p>
<p>Joomla code licensed under the <a href="http://www.gnu.org/licenses/old-licenses/gpl-2.0.html" target="_blank">GPL version 2.0</a>.</p>
<p>Template by <a href="https://github.com/KISS-Web-Design/kwd-j-bootstrap">KISS Web Design</a>, licenced under the <a href="http://www.gnu.org/licenses/old-licenses/gpl-2.0.html" target="_blank">GPL version 2.0</a>.</p>
</div>
</div>      

How it relates to this template

The page header (above the blue menu in position section-r2-1) and footer are both span12 module positions with "Custom HTML" modules assigned to them.

The blue menu bar is in position nav-r3 and the menu module has the classes menu nav nav-pills applied.

Each sub-section of this page is a Joomla! article. Written using CodeMirror as the default editor, to enable the easy writing of HTML and utilising the bootstrap CSS classes. You could use any editor for your articles, I just prefer writing raw HTML. But then I am a coder, so it feels more natural to me.


Custom Template Design

You can use this template a jumping-off point for your own bootstrapped template. The simplest way to do this is by customising the LESS files so you have your own colour scheme and font choices.

You can change anything about this template, providing you abide by the licences, by forking the project on Github.

If you don't want to do it yourself, KISS Web Design can do it for you, to your specification. Contact us on our website or by email to This email address is being protected from spambots. You need JavaScript enabled to view it. and we will get back to you as soon as we can.