40
Building Responsive Websites with the Bootstrap 3 Framework Michael Slater and Charity Grace Kirk [email protected] 888.670.6793 1

Building Responsive Websites with the Bootstrap 3 Framework

Embed Size (px)

DESCRIPTION

For more resources, see http://www.webvanta.com/bootstrap The Bootstrap HTML/CSS/JavaScript framework, originally created by Twitter, provides an outstanding starting point for building a custom website. It is built to modern HTML5 and CSS3 coding standards; it provides a variety of common user interface widgets; it establishes an attractive baseline for typography; and, best of all, it fully supports responsive designs that perform well on phones and tablets, as well as on desktops. In this webinar, Webvanta CEO Michael Slater and senior developer Charity Grace Kirk will explain how the Bootstrap framework works and how to use it as the starting point for your own sites. Topics covered include: Bootstrap's approach to responsive design and mobile support User interface components provided by the Boostrap CSS, including buttons, navigation bars, and responsive images The grid system, and how to use it to create optimized designs for all screen widths How to use Bootstrap's JavaScript library to create tabs, collapsible sections, carousels, alerts, and more without writing a single line of JavaScript code Techniques for customizing Bootstrap to make your site look and behave exactly how you want

Citation preview

Page 1: Building Responsive Websites with the Bootstrap 3 Framework

Building Responsive Websites with the

Bootstrap 3 Framework

Michael Slater and Charity Grace Kirk

[email protected]

1

Page 2: Building Responsive Websites with the Bootstrap 3 Framework

Today’s PresentersMichael Slater

‣ President and Cofounder of Webvanta

‣ Has been creating content-rich websites since the web’s early days

‣ Previously director of technology strategy at Adobe Systems

Charity Grace Kirk‣ Senior web developer at Webvanta

‣ More than 5 years experience building sites for clients on the Webvanta platform

‣ Experience in content strategy, search engine optimization, and online marketing.

2

Page 3: Building Responsive Websites with the Bootstrap 3 Framework

Asking QuestionsNow

• Ask questions by entering the textin the GoToWebinar control panel

Later

• Follow up with us afterwards ([email protected]) if you have questions that didn’t get addressed

• Link to slides, video, and code will be emailed to you tomorrow

3

Page 4: Building Responsive Websites with the Bootstrap 3 Framework

What is Your Role in Building Websites?

• Designer

• Developer

• Manager

4

Page 5: Building Responsive Websites with the Bootstrap 3 Framework

Why Responsive Design?

5

Page 6: Building Responsive Websites with the Bootstrap 3 Framework

Adapt to a wide range of screen sizes

6

http://www.tempeazdentist.com

Page 7: Building Responsive Websites with the Bootstrap 3 Framework

Desktop-focused sites arehard to use on phones

7

Page 8: Building Responsive Websites with the Bootstrap 3 Framework

Google encouraging responsive design

8

Searches on mobile phones should link to mobile-friendly content

Page 9: Building Responsive Websites with the Bootstrap 3 Framework

How much of your browsing is on a phone or tablet?

• None

• Less than 10%

• 10% to 40%

• About half

• More than half

9

Page 10: Building Responsive Websites with the Bootstrap 3 Framework

Mobile is Exploding!

Mobile devices (phones and tablets)

‣ Now account for ~20% of all web traffic

‣ Higher for restaurants, hotels

Black Friday mobile traffic

‣ Up 34% from last year, sales up 43%

‣ 21.6% of all online sales from mobile

10

Page 11: Building Responsive Websites with the Bootstrap 3 Framework

The Mobile Site Alternative

11

jQuery Mobilewith Server-side

mobile detection

http://arthistory.berkeley.edu

Page 12: Building Responsive Websites with the Bootstrap 3 Framework

Responsive Design Basics

• Uses CSS Media Queries

• More than just fluid design

‣ Columns can stack at smaller widths

‣ Sizes, padding, margin … all can adjust

‣ Elements can be hidden or swapped out

12

Page 13: Building Responsive Websites with the Bootstrap 3 Framework

CSS Media Queries

13

For Example:

@media (min-width: 440px) and (max-width: 767px) { h1.logo { text-align: center; } .subtitle { display: none; }

}

rule will only apply to screens440px wide to 767 px wide

Page 14: Building Responsive Websites with the Bootstrap 3 Framework

Media QueryBrowser Support

• Chrome, Firefox, Safari, Opera

‣ All reasonably recent versions

• IE10 fully supported

• IE9: except for a few CSS enhancements

• IE8: requires respond.js and html5shiv.js

• IE7: not officially supported, but “should look and behave well enough”

14

Page 15: Building Responsive Websites with the Bootstrap 3 Framework

Why Bootstrap?Speed up development

‣ Responsive grid system

‣ Quality default typography

‣ Common components

‣ Popular jQuery plugins

‣ Simplifies “bootstrapping” your design

15

Page 16: Building Responsive Websites with the Bootstrap 3 Framework

What is Bootstrap?• Created by Twitter, published as open

source

• Consists of a CSS file, a JS file, and an icon font

• CSS is compiled from LESS source

• JS can be loaded in “everything” version or only selected pieces

‣ Requires jQuery

16

Page 17: Building Responsive Websites with the Bootstrap 3 Framework

Mobile-First StrategyContent

• Determine what is most important

Layout

• Design to smaller widths first

• Base CSS addresses phones; media queries for tablet and desktop

Progressive enhancement

• Add elements as screen size increases

17

Page 18: Building Responsive Websites with the Bootstrap 3 Framework

Bootstrap Break Points

18

/* Extra small devices (“phones”, less than 768px) *//* No media query need as this is the default Bootstrap */

/* Small devices (“tablets”, 768px and up) */@media (min-width: 768px) { ... }

/* Medium devices (“desktops”, 992px and up) */@media (min-width: 992px) { ... }

/* Large devices (“large desktops”, 1200px and up) */@media (min-width: 1200px) { ... }

Page 19: Building Responsive Websites with the Bootstrap 3 Framework

Responsive Grid

• Standard grid is 12 columns wide

• Fluid by default, then 3 fixed widths

19

designwidth

fluid 750px 970px 1170px

max column

100% 60px 78px 95px

Page 20: Building Responsive Websites with the Bootstrap 3 Framework

Basic Grid Structure• <div class=“container”>

‣ <div class=“row”>

• <div class=“col-*-*”></div>

• <div class=“col-*-*”></div>

‣ </div>

‣ <div class=“row”>… </div>

• <div class=“container”>

‣ ...

20

Page 21: Building Responsive Websites with the Bootstrap 3 Framework

Example 1understanding .col-md-*

21

See grid.html

Page 22: Building Responsive Websites with the Bootstrap 3 Framework

Controlling the Grid

• Each breakpoint has its own grid class

‣ .col-xs-*, .col-sm-*, .col-md-*, .col-lg-*

• Below the smallest defined breakpoint for a column, it stacks vertically

22

Page 23: Building Responsive Websites with the Bootstrap 3 Framework

Example 2easy column scaling up and down

23

See grid2.html

Page 24: Building Responsive Websites with the Bootstrap 3 Framework

Ordering the Grid

• Push and Pull columns to position on larger widths.

‣ e.g. .col-md-push-* or .col-md-pull-*

24

Page 25: Building Responsive Websites with the Bootstrap 3 Framework

Example 3easy column positioning

25

See grid3.html

Page 26: Building Responsive Websites with the Bootstrap 3 Framework

Responsive Images• Background Images in CSS

‣ Can load appropriate-size image based on viewport size (via media queries)

• Images in HTML (<img src="filename.jpg">)

‣ Class .img-responsive sets max-width to 100%

‣ Browser scales images to fit container, but doesn’t allow them to get pixelated

26

Page 27: Building Responsive Websites with the Bootstrap 3 Framework

Helper Classes• Bootstrap includes a variety of CSS

classes to help make markup more semantic

‣ pull-left, pull-right

‣ center-block, text-right, text-center …

‣ clearfix

‣ visible-xs, hidden-xs, visible-md …

27

Page 28: Building Responsive Websites with the Bootstrap 3 Framework

Navigation

28

Horizontal NavVertical Toggle Nav

http://www.wchealth.org

Page 29: Building Responsive Websites with the Bootstrap 3 Framework

JavaScript Features• Many common JavaScript-based plugins

and functions included

‣ Carousel, transitions

‣ Modal, alert

‣ Dropdown, tab, tooltip, popover, button

‣ Collapse

‣ Scrollspy

29

Page 30: Building Responsive Websites with the Bootstrap 3 Framework

JavaScript without JavaScript

• CSS classes and HTML5 data attributes used to trigger behavior

• Bootstrap JS file finds these attributes and uses them to active JS and CSS code

30

Page 31: Building Responsive Websites with the Bootstrap 3 Framework

JavaScript Plugin Examples

see widgets.html

31

Page 32: Building Responsive Websites with the Bootstrap 3 Framework

Visual Components• Icon library

• Buttons

• Breadcrumbs

• Pagination

• Navbar

• Progress bar

• ... and more

32

Page 33: Building Responsive Websites with the Bootstrap 3 Framework

Does Bootstrap seem like a good fit for you?

• No (don’t plan to support mobile)

• No (plan to support mobile differently)

• Probably, I need to learn more

• Yes, I can’t wait!

33

Page 34: Building Responsive Websites with the Bootstrap 3 Framework

Customizing

• Add your own CSS file after the Bootstrap file to override and add classes

• Can edit source LESS files and recompile into customized CSS

‣ Upgrading to new Bootstrap version can be difficult

34

Page 35: Building Responsive Websites with the Bootstrap 3 Framework

Other ResponsiveFrameworks

• Foundation (foundation.zurb.com)

• Skeleton (getskeleton.com)

35

Page 36: Building Responsive Websites with the Bootstrap 3 Framework

Get Started!

getbootstrap.com

www.webvanta.com/trial

36

Page 37: Building Responsive Websites with the Bootstrap 3 Framework

Webvanta SmartTheme

• Gives you an instant start

• Fully hosted, all code in place

• Integrate with database-driven content

• The fast way to a powerful, custom and responsive site

• Join our January webinar

37

Page 38: Building Responsive Websites with the Bootstrap 3 Framework

What are yourmajor questions?

• Let us know what more you’d like to know and we’ll use it to guide our upcoming articles and webinars

38

Page 39: Building Responsive Websites with the Bootstrap 3 Framework

We’re Here to Help• Webvanta specializes in creating content-rich

sites that deliver on business goals

• Get your private consultation

‣ Free 30-minute consultation

‣ email [email protected] or call 888.670.6793

• Learn more online and stay in touch

‣ www.webvanta.com/blog

‣ www.facebook.com/webvanta

39

Page 40: Building Responsive Websites with the Bootstrap 3 Framework

40

241 South Main StreetSebastopol, CA 95472

[email protected]

www.webvanta.comt