Getting Started with Bootstrap 3
Looking to immerse yourself in the world of web development and responsive web design? Twitter’s Bootstrap is a great way for budding developers to get their feet wet and for veteran developers to save a ridiculous amount of development time with this boilerplate HTML/CSS/JS library. For newbies and veterans alike, you have fully compiled, minified, […]
May 19, 2016 | 5 min. read
Looking to immerse yourself in the world of web development and responsive web design? Twitter’s Bootstrap is a great way for budding developers to get their feet wet and for veteran developers to save a ridiculous amount of development time with this boilerplate HTML/CSS/JS library. For newbies and veterans alike, you have fully compiled, minified, syntactically-awesome libraries to include in your web project — along with well thought-out documentation to guide you. Bootstrap provides you with predefined classes, styles, and scripts to get your web project up and running while reducing your initial development workload.
Here is how you can get started with Bootstrap 3!
Include Bootstrap resources in your <head></head> (or if working on a WordPress platform, include them via functions.php). You can deliver these libraries via Bootstrap’s CDN (extremely fast delivery, most likely a much faster response time than a shared host request) or you can download them and include the files in your local website directory. Be sure to include your custom stylesheets after Bootstrap CSS and jQuery before Bootstrap JS.
Including via CDN (copy-pasta):
The navbar is a responsive element that contains your website’s navigation. You can modify this element with the many predefined classes here. The breakpoint for this element (when the responsive menu kicks in) is 767px.
Bootstrap comes loaded with many useful icons, particularly useful for UI elements, or content indicators. Add any of the classes from this list to any icon element on your web project and you’ve got fully rasterized, vector icons.
Bootstrap is famous for it’s responsive grid classes, these classes will help you implement responsive features to the elements on your page without having to write any custom styles or define any media queries! The idea is this: responsive elements are contained within a row (defined by class=”row”) and the elements therein are defined with classes that decide at which breakpoint the content will become “responsive” or reorganize on the user’s screen for the optimal mobile viewing experience. Each “row” contains elements in combinations of 12 “columns” defined by the class=”col-(size)-(#)”. The (size) can be replaced by “xs”, “sm”, “md” or “lg” telling the browser which breakpoint to restructure content on. The (#) can be replaced by any number 1-12 to define the width of the column for each breakpoint.
From Bootstrap Docs:
Grid systems are used for creating page layouts through a series of rows and columns that house your content. Here’s how the Bootstrap grid system works:
- Rows must be placed within a
.container-fluid(full-width) for proper alignment and padding.
- Use rows to create horizontal groups of columns.
- Content should be placed within columns, and only columns may be immediate children of rows.
- Predefined grid classes like
.col-xs-4are available for quickly making grid layouts. Less mixins can also be used for more semantic layouts.
- Columns create gutters (gaps between column content) via
padding. That padding is offset in rows for the first and last column via negative margin on
- The negative margin is why the examples below are outdented. It’s so that content within grid columns is lined up with non-grid content.
- Grid columns are created by specifying the number of twelve available columns you wish to span. For example, three equal columns would use three
- If more than 12 columns are placed within a single row, each group of extra columns will, as one unit, wrap onto a new line.
- Grid classes apply to devices with screen widths greater than or equal to the breakpoint sizes, and override grid classes targeted at smaller devices. Therefore, e.g. applying any
.col-md-*class to an element will not only affect its styling on medium devices but also on large devices if a
.col-lg-*class is not present.
Look to the examples for applying these principles to your code.
Read the full docs on Bootstrap grids here.
Simply add the class “img-responsive” and any image will scale to the width of your screen (limited by the width of the container of the image element). Image not centering on larger resolutions? Add the “center-block” class following “img-responsive” to center the image in the container. More handy responsive classes for images here.
Bootstrap’s custom theme comes with defined classes for buttons, links, and more! See a list of custom styles for buttons here.
More Bootstrap Goodies
The full documentation can be found here. If you’re serious about utilizing Bootstrap to it’s full potential, I highly recommend you spend some time reading through the documentation to get a feel for what Bootstrap has to offer!
Subscribe to our newsletter and get more awesome content like this article.