Book Image

Extending Bootstrap

By : Christoffer Niska
Book Image

Extending Bootstrap

By: Christoffer Niska

Overview of this book

<p>Bootstrap is a free collection of tools used to create websites and web applications. It contains HTML- and CSS-based design templates for typography, forms, buttons, navigation and other interface components, as well as optional JavaScript extensions. Much has been written and said recently, in the world of web design and development, about Bootstrap. Some people call it a boon for web developers with little designing knowledge, while others call it a blessing for the designers. A user familiar with all that Bootstrap has to offer can extend the framework so that it no longer has the original look and feel of Twitter. This will allow you to use clever and novel ways of taking the power the standard library of Bootstrap has, and transform it into what you have envisioned.<br /><br />This is a practical, step-by-step guide to extending Bootstrap. It covers all the aspects of extending Bootstrap, including themes, customization, extending its plugins, and an introduction to several third- party Bootstrap plugins.<br /><br />Once you understand why you should use Bootstrap in the first place, you will learn about custom themes. This book then walks you through customization with CSS, and introduces you to LESS. You will learn to use Grunt.js to generate your own custom build of Bootstrap, customize plugins and grids, and even build custom plugins! Finally you will explore the most useful third-party plugins for Bootstrap and end with creating your first Bootswatch theme. This is a complete guide to unlocking the true power of Bootstrap.</p>
Table of Contents (16 chapters)

Creating your first Bootstrap project


Now that you know when it is suitable to use Bootstrap, you are ready to start your first Bootstrap project. Perform the following steps to get started:

  1. Create a new folder for your Bootstrap project inside your document root. You can call it bootstrap-app.

  2. Pick up the latest version of Bootstrap from http://getbootstrap.com and unpack it into your project directory.

  3. Create a new HTML document, add the following contents, and save it in your project directory as index.html in the following manner:

    <!DOCTYPE html>
    <html>
      <head>
        <title>Hello from Bootstrap</title>
        <!-- Ensure proper rendering and touch zooming on mobiledevices -->
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <link href="css/bootstrap.min.css" rel="stylesheet">
        <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elementsand media queries -->
        <!--[if lt IE 9]>
          <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
          <script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>
        <![endif]-->
      </head>
      <body>
        <h1>Hello, world!</h1>
      </body>
    </html>

    Tip

    You can omit html5shiv.js and respond.js if you don't wish to support older versions of Internet Explorer.

Let us look at the following reasons why we included all those CSS and JavaScript files:

  • bootstrap.min.css: It is the minified version of the Bootstrap CSS styles

  • html5shiv.js: It adds HTML5 support to older browsers

  • respond.min.js: It adds media query support to older browsers

Navigate to your project directory using your favorite web browser; you should see your project in action as shown in the following screenshot. Not too impressive, but do not worry, you will soon add more to it.

Tip

For more information on how to get started with Bootstrap, refer to the Getting started page on the official site at http://getbootstrap.com/getting-started/.