Top Banner
Stop Reinventing the Wheel Build Responsive Websites Using Bootstrap Framework Gaurav Gupta HighEdWeb Conference, October 5, 2015 #DPA3 @FrshBakedPixels
116

Stop reinventing the wheel: Build Responsive Websites Using Bootstrap

Apr 16, 2017

Download

Design

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Stop reinventing the wheel: Build Responsive Websites Using Bootstrap

Stop Reinventing the WheelBuild Responsive Websites Using Bootstrap Framework

Gaurav Gupta HighEdWeb Conference, October 5, 2015

#DPA3 @FrshBakedPixels

Page 2: Stop reinventing the wheel: Build Responsive Websites Using Bootstrap

#DPA3

@FrshBakedPixels

Page 3: Stop reinventing the wheel: Build Responsive Websites Using Bootstrap

about meIT Analyst

Division of Learning Innovation and Student Success

Virginia Commonwealth University

#DPA3 @FrshBakedPixels

Page 4: Stop reinventing the wheel: Build Responsive Websites Using Bootstrap

evolution of web design

Page 5: Stop reinventing the wheel: Build Responsive Websites Using Bootstrap

Table Div + Float Grid ResponsiveWeb Design

Page 6: Stop reinventing the wheel: Build Responsive Websites Using Bootstrap

float:none

float:left float: right

Table Div + Float Grid ResponsiveWeb Design

Page 7: Stop reinventing the wheel: Build Responsive Websites Using Bootstrap

12 columns

4 columns

6 columns 6 columns

4 columns 4 columns

Table Div + Float Grid ResponsiveWeb Design

Page 8: Stop reinventing the wheel: Build Responsive Websites Using Bootstrap

12 3

Table Div + Float Grid ResponsiveWeb Design

Page 9: Stop reinventing the wheel: Build Responsive Websites Using Bootstrap

1

2

3

Table Div + Float Grid ResponsiveWeb Design

Page 10: Stop reinventing the wheel: Build Responsive Websites Using Bootstrap
Page 11: Stop reinventing the wheel: Build Responsive Websites Using Bootstrap

Media queries

Responsive grid

Responsive images

Page 12: Stop reinventing the wheel: Build Responsive Websites Using Bootstrap

desktop mobile

Page 13: Stop reinventing the wheel: Build Responsive Websites Using Bootstrap

Media queries

Responsive grid

Responsive images

Page 14: Stop reinventing the wheel: Build Responsive Websites Using Bootstrap

responsive navigation

desktop

mobile

Page 15: Stop reinventing the wheel: Build Responsive Websites Using Bootstrap

responsive forms

desktop

mobile

Page 16: Stop reinventing the wheel: Build Responsive Websites Using Bootstrap

responsive media embed

desktop

mobile

Page 17: Stop reinventing the wheel: Build Responsive Websites Using Bootstrap

#DPA3 @FrshBakedPixels

Page 18: Stop reinventing the wheel: Build Responsive Websites Using Bootstrap

CSS and JavaScript framework

Originally developed by Twitter

Made open source in October 2011

Currently Version 3.3.5

#DPA3 @FrshBakedPixels

Page 19: Stop reinventing the wheel: Build Responsive Websites Using Bootstrap

why Bootstrap

#DPA3 @FrshBakedPixels

Page 20: Stop reinventing the wheel: Build Responsive Websites Using Bootstrap

wide browser anddevice support

Page 21: Stop reinventing the wheel: Build Responsive Websites Using Bootstrap

re-usable components

Page 22: Stop reinventing the wheel: Build Responsive Websites Using Bootstrap

standardized code

Page 23: Stop reinventing the wheel: Build Responsive Websites Using Bootstrap

open-source andcustomizable

Page 24: Stop reinventing the wheel: Build Responsive Websites Using Bootstrap

thoroughly tested and debugged

#DPA3 @FrshBakedPixels

Page 25: Stop reinventing the wheel: Build Responsive Websites Using Bootstrap

Source: http://trends.builtwith.com/docinfo/Twitter-Bootstrap

Page 26: Stop reinventing the wheel: Build Responsive Websites Using Bootstrap

#DPA3 @FrshBakedPixels

Page 27: Stop reinventing the wheel: Build Responsive Websites Using Bootstrap

Source: http://us.pg.com

Page 28: Stop reinventing the wheel: Build Responsive Websites Using Bootstrap

Source: http://statefarm.com

Page 29: Stop reinventing the wheel: Build Responsive Websites Using Bootstrap

Source: http://centralusa.salvationarmy.org/

Page 30: Stop reinventing the wheel: Build Responsive Websites Using Bootstrap

Source: http://www.washington.edu

Page 31: Stop reinventing the wheel: Build Responsive Websites Using Bootstrap

Source: http://www4.uwm.edu/

Page 32: Stop reinventing the wheel: Build Responsive Websites Using Bootstrap

Source: http://arkansas.gov

http://arkansas.gov/

Page 33: Stop reinventing the wheel: Build Responsive Websites Using Bootstrap

Source: http://www.nps.gov//

Page 34: Stop reinventing the wheel: Build Responsive Websites Using Bootstrap
Page 35: Stop reinventing the wheel: Build Responsive Websites Using Bootstrap

Repeal Bootstrap

Page 36: Stop reinventing the wheel: Build Responsive Websites Using Bootstrap
Page 37: Stop reinventing the wheel: Build Responsive Websites Using Bootstrap

what’s included in Bootstrap

#DPA3 @FrshBakedPixels

Page 38: Stop reinventing the wheel: Build Responsive Websites Using Bootstrap

Responsive grid system 12 column grid

4 different screen sizes

nestable

#DPA3 @FrshBakedPixels

Page 39: Stop reinventing the wheel: Build Responsive Websites Using Bootstrap

Responsive grid system

Pre-styled elements Navigation bar

Drop-down menus

Forms

Buttons

Tables

Labels and Badges

#DPA3 @FrshBakedPixels

Page 40: Stop reinventing the wheel: Build Responsive Websites Using Bootstrap

pre-styled buttons

<a class="btn btn-default">Default button</a>

<a class="btn btn-primary btn-lg">Large button</a>

<a class="btn btn-primary">Primary button</a>

<a href="#">Button</a>

Page 41: Stop reinventing the wheel: Build Responsive Websites Using Bootstrap

pre-styled form elements

Page 42: Stop reinventing the wheel: Build Responsive Websites Using Bootstrap

Responsive grid system

Pre-styled elements

Icon font Glyphicons

180 icons

#DPA3 @FrshBakedPixels

Page 43: Stop reinventing the wheel: Build Responsive Websites Using Bootstrap

icon font<span class="glyphicon glyphicon-search"></span>

<span class="glyphicon glyphicon-envelope"></span>

<span class="glyphicon glyphicon-home"></span>

<span class="glyphicon glyphicon-pencil"></span>

<span class="glyphicon glyphicon-refresh"></span>

<span class="glyphicon glyphicon-shopping-cart"></span>

<span class="glyphicon glyphicon-cog"></span>

#DPA3 @FrshBakedPixels

Page 44: Stop reinventing the wheel: Build Responsive Websites Using Bootstrap

icon font

16px

48px

96px

#DPA3 @FrshBakedPixels

Page 45: Stop reinventing the wheel: Build Responsive Websites Using Bootstrap

what’s includedResponsive grid system

Pre-styled elements

Icon font

JavaScript plugins

Modal Drop-down Tab Collapse Tooltip and Popover Carousel Scrollspy Affix

#DPA3 @FrshBakedPixels

Page 46: Stop reinventing the wheel: Build Responsive Websites Using Bootstrap

http://getbootstrap.com/

Page 47: Stop reinventing the wheel: Build Responsive Websites Using Bootstrap

you can choose and customize

#DPA3 @FrshBakedPixels

Page 48: Stop reinventing the wheel: Build Responsive Websites Using Bootstrap

Bootstrap folder

structure

Page 49: Stop reinventing the wheel: Build Responsive Websites Using Bootstrap

you will also need

jQuery

For IE8 and below respond.js (media queries)

html5shiv.js (HTML5 support)

#DPA3 @FrshBakedPixels

Page 50: Stop reinventing the wheel: Build Responsive Websites Using Bootstrap

let’s build something

#DPA3 @FrshBakedPixels

Page 51: Stop reinventing the wheel: Build Responsive Websites Using Bootstrap

http://tiny.cc/heweb1

Page 52: Stop reinventing the wheel: Build Responsive Websites Using Bootstrap

Start with HTML5 document

<!DOCTYPE HTML> <html> <head></head> <body> <header></header> <nav></nav> <section></section> <section></section> <section></section> <section></section> <footer></footer> </body> </html>

Page 53: Stop reinventing the wheel: Build Responsive Websites Using Bootstrap

<!DOCTYPE HTML> <html> <head>

</head> <body> <header></header> <nav></nav> <section></section> <section></section> <section></section> <section></section> <footer></footer>

</body> </html>

<link rel="stylesheet" href="css/bootstrap.css"><meta name="viewport" content="width=device-width, initial-scale=1.0">

<!--[if lt IE 9]> <script src="js/html5shiv.js"></script> <script src="js/respond.min.js"></script> <![endif]-->

<script src="js/jquery.js"></script> <script src="js/bootstrap.min.js"></script>

<link rel="stylesheet" href="css/myCustomStylesheet.css">

Page 54: Stop reinventing the wheel: Build Responsive Websites Using Bootstrap

responsive grid 101

#DPA3 @FrshBakedPixels

Page 55: Stop reinventing the wheel: Build Responsive Websites Using Bootstrap

Breakpoint

Page 56: Stop reinventing the wheel: Build Responsive Websites Using Bootstrap

Breakpoint

Page 57: Stop reinventing the wheel: Build Responsive Websites Using Bootstrap

Breakpoint

Page 58: Stop reinventing the wheel: Build Responsive Websites Using Bootstrap

Breakpoint

Page 59: Stop reinventing the wheel: Build Responsive Websites Using Bootstrap

Breakpoint

Page 60: Stop reinventing the wheel: Build Responsive Websites Using Bootstrap

Breakpoint

Page 61: Stop reinventing the wheel: Build Responsive Websites Using Bootstrap

Bootstrap has 3 breakpoints

992px 1200px768px

extra-small small medium large.col-xs- .col-lg-.col-md-.col-sm-

Page 62: Stop reinventing the wheel: Build Responsive Websites Using Bootstrap

<div class="col-md-3">col-md-3</div> <div class="col-md-9">col-md-9</div>

screen size prefixes

relative width of columns numbers must add up to 12

.col-­‐md-­‐3 .col-­‐md-­‐9

<div class="row">

</div>

Page 63: Stop reinventing the wheel: Build Responsive Websites Using Bootstrap

<section class="row"> <div class="col-md-3">

</div> <div class="col-md-9">

</div> </section>

“about me” section

<h2>about me</h2>

<p>I work as an …</p> <p>My area of interest …</p>

Page 64: Stop reinventing the wheel: Build Responsive Websites Using Bootstrap

small screen

medium screen

“about me” section

Page 65: Stop reinventing the wheel: Build Responsive Websites Using Bootstrap

really large screen

“about me” section

Page 66: Stop reinventing the wheel: Build Responsive Websites Using Bootstrap

<div class="row"> <div class="col-md-8">col-md-8</div> <div class="col-md-4">col-md-4</div> </div>

sets maximum width center aligns the container

really large screen

<div class="container">

</div>

Page 67: Stop reinventing the wheel: Build Responsive Websites Using Bootstrap

header

<header class="container"> <div class="row"> <div class="col-sm-5"> <img src="images/gaurav.png"> </div> <div class="col-sm-7"> <h1>Gaurav Gupta</h1> <p>web designer, developer</p> </div> </div> </header>

Page 68: Stop reinventing the wheel: Build Responsive Websites Using Bootstrap
Page 69: Stop reinventing the wheel: Build Responsive Websites Using Bootstrap

change column order<header class="container"> <div class="row">

</div> </header>

<div class="col-sm-5 col-sm-pull-7 "> <img src="images/gaurav.png"> </div>

<div class="col-sm-7 col-sm-push-5 "> <h1>Gaurav Gupta</h1> <p>web designer, developer</p> </div>

Page 70: Stop reinventing the wheel: Build Responsive Websites Using Bootstrap

change column order<header class="container"> <div class="row">

</div> </header>

<div class="col-sm-5 col-sm-pull-7 "> <img src="images/gaurav.png"> </div>

<div class="col-sm-7 col-sm-push-5 "> <h1>Gaurav Gupta</h1> <p>web designer, developer</p> </div>

Page 71: Stop reinventing the wheel: Build Responsive Websites Using Bootstrap

mix and match grid columnscolumn  1 column  2 column  3

<div class="row"> <div class="col-md-6 col-sm-12">column 1</div> <div class="col-md-4 col-sm-6" >column 2</div> <div class="col-md-2 col-sm-6" >column 3</div> </div>

column  1

column  2 column  3 »

medium screens

small screens

Page 72: Stop reinventing the wheel: Build Responsive Websites Using Bootstrap

responsive images<img src="... " class="img-responsive">

Page 73: Stop reinventing the wheel: Build Responsive Websites Using Bootstrap

responsive tables

<div class="table-responsive"> <table class="table"> ... </table> </div>

Page 74: Stop reinventing the wheel: Build Responsive Websites Using Bootstrap

responsive navigation

#DPA3 @FrshBakedPixels

Page 75: Stop reinventing the wheel: Build Responsive Websites Using Bootstrap

start with basic markup<nav> <ul> <li><a href="#home">home</a></li> <li><a href="#about">about me</a></li> <li><a href="#projects">recent projects</a></li> <li><a href="#presentations">presentations</a></li> <li><a href="#contact">contact me</a></li> </ul> </nav>

Page 76: Stop reinventing the wheel: Build Responsive Websites Using Bootstrap

add classes<nav class="navbar navbar-default"> <ul class="nav nav-justified"> <li><a href="#home">home</a></li> <li><a href="#about">about me</a></li> <li><a href="#projects">recent projects</a></li> <li><a href="#presentations">presentations</a></li> <li><a href="#contact">contact me</a></li> </ul> </nav>

small – large screens

extra-small screen

Page 77: Stop reinventing the wheel: Build Responsive Websites Using Bootstrap

collapse navigation on extra-small screens

<nav class="navbar navbar-default"> <ul class="nav nav-justified collapse navbar-collapse"> ... </ul> </nav>

Page 78: Stop reinventing the wheel: Build Responsive Websites Using Bootstrap

add toggle button<nav> <div class="navbar-header visible-xs"> <button class="navbar-toggle" data-toggle="collapse" data-target=".my-navbar"> <span class="glyphicon glyphicon-align-justify"></span> </button> </div> <ul class="nav nav-justified collapse navbar-collapse my-navbar" > ... </ul> </nav>

Page 79: Stop reinventing the wheel: Build Responsive Websites Using Bootstrap

add header text

<div class="navbar-header visible-xs"> <button class="navbar-toggle" data-toggle="collapse" data-target=".my- navbar"> <span class="glyphicon glyphicon-align-justify"></span> <h3 class=" text-center">Gaurav Gupta</h3> </button> </div>

Page 80: Stop reinventing the wheel: Build Responsive Websites Using Bootstrap

small – large screens

extra-small screen

Page 81: Stop reinventing the wheel: Build Responsive Websites Using Bootstrap

adding your own styles

#DPA3 @FrshBakedPixels

Page 82: Stop reinventing the wheel: Build Responsive Websites Using Bootstrap

/* myCustomStylesheet.css */

.navbar-default { background-color: #74716a; border-color: #FFF; }

/* bootstrap.css */

.navbar-default { background-color: #f8f8f8; border-color: #e7e7e7; }

Page 83: Stop reinventing the wheel: Build Responsive Websites Using Bootstrap

use web developer tools

»

Page 84: Stop reinventing the wheel: Build Responsive Websites Using Bootstrap

JavaScript components

#DPA3 @FrshBakedPixels

Page 85: Stop reinventing the wheel: Build Responsive Websites Using Bootstrap

Affix: fix position of elements on page $('nav').affix({offset: {top: ($('nav').offset().top), bottom: 200} });

nav.affix { top: 0; width: 100%;}

»

Page 86: Stop reinventing the wheel: Build Responsive Websites Using Bootstrap

Scrollspy: indicate current location <body data-spy="scroll" data-target=".nav">

nav .nav > li.active > a { background-color: #514F4A; }

»

Page 87: Stop reinventing the wheel: Build Responsive Websites Using Bootstrap

tabs

Page 88: Stop reinventing the wheel: Build Responsive Websites Using Bootstrap

tabs<ul class="nav nav-tabs"> <li><a href="#contactme" data-toggle="tab">Contact me</a></li> <li><a href="#twitter" data-toggle="tab">Twitter</a></li> <li><a href="#services" data-toggle="tab">Services</a></li> </ul>

Page 89: Stop reinventing the wheel: Build Responsive Websites Using Bootstrap

tabs<div class="tab-content"> <div class="tab-pane" id="contactme">...</div> <div class="tab-pane" id="twitter">...</div> <div class="tab-pane" id="services">...</div> </div>

Page 90: Stop reinventing the wheel: Build Responsive Websites Using Bootstrap

tooltip

<input type="text" data-toggle="tooltip" title="full name">

$('[data-toggle="tooltip"]').tooltip();

Page 91: Stop reinventing the wheel: Build Responsive Websites Using Bootstrap

Bootstrap + 146 lines of CSS + 10 lines of JS

Page 92: Stop reinventing the wheel: Build Responsive Websites Using Bootstrap

#DPA3 @FrshBakedPixels

Page 93: Stop reinventing the wheel: Build Responsive Websites Using Bootstrap
Page 94: Stop reinventing the wheel: Build Responsive Websites Using Bootstrap

more examples on Bootstrap website

Page 95: Stop reinventing the wheel: Build Responsive Websites Using Bootstrap

retrofitting an existing website

#DPA3 @FrshBakedPixels

Page 96: Stop reinventing the wheel: Build Responsive Websites Using Bootstrap

Apple page built with Bootstrap

http://tiny.cc/heweb2

8-10 hours

Page 97: Stop reinventing the wheel: Build Responsive Websites Using Bootstrap

other ways to use Bootstrap

#DPA3 @FrshBakedPixels

Page 98: Stop reinventing the wheel: Build Responsive Websites Using Bootstrap

prototyping

Page 99: Stop reinventing the wheel: Build Responsive Websites Using Bootstrap

Wordpress plugins

Page 100: Stop reinventing the wheel: Build Responsive Websites Using Bootstrap
Page 101: Stop reinventing the wheel: Build Responsive Websites Using Bootstrap

third party add-ons

Page 102: Stop reinventing the wheel: Build Responsive Websites Using Bootstrap

Fontello

»

Page 103: Stop reinventing the wheel: Build Responsive Websites Using Bootstrap

Bootsnipp: button builder

http://bootsnipp.com/buttons »

Page 104: Stop reinventing the wheel: Build Responsive Websites Using Bootstrap

pros and cons of Bootstrap

#DPA3 @FrshBakedPixels

Page 105: Stop reinventing the wheel: Build Responsive Websites Using Bootstrap

The easy way of building websites, not the ideal way

Overstyled components

Unused CSS

Page 106: Stop reinventing the wheel: Build Responsive Websites Using Bootstrap
Page 107: Stop reinventing the wheel: Build Responsive Websites Using Bootstrap

version 4.0

#DPA3 @FrshBakedPixels

Page 108: Stop reinventing the wheel: Build Responsive Websites Using Bootstrap

Dropped IE 8 support

Use of Em and Rem instead of pixels

Added one more breakpoint

Flexbox layout support

Page 109: Stop reinventing the wheel: Build Responsive Websites Using Bootstrap

other frameworks

#DPA3 @FrshBakedPixels

Page 110: Stop reinventing the wheel: Build Responsive Websites Using Bootstrap
Page 111: Stop reinventing the wheel: Build Responsive Websites Using Bootstrap
Page 112: Stop reinventing the wheel: Build Responsive Websites Using Bootstrap
Page 113: Stop reinventing the wheel: Build Responsive Websites Using Bootstrap

Source: http://usablica.github.io/front-end-frameworks/compare.html

Page 114: Stop reinventing the wheel: Build Responsive Websites Using Bootstrap

my selection criteria

responsive

browser support

features

popularity

Page 115: Stop reinventing the wheel: Build Responsive Websites Using Bootstrap

other resources50 Must-have Bootstrap plugins http://tutorialzine.com/2013/07/50-must-have-plugins-for-extending-twitter-bootstrap/

Bootply http://www.bootply.com/

Bootstrap CDN http://www.bootstrapcdn.com/

More resources http://bootsnipp.com/resources

Inspect structure and style with Chrome Developer Tools

https://developers.google.com/web/tools/iterate/inspect-styles/basics

Page 116: Stop reinventing the wheel: Build Responsive Websites Using Bootstrap

questions?

#DPA3

@frshbakedpixels