bootstrap: the full overview

99

Upload: gill-cleeren

Post on 03-Aug-2015

216 views

Category:

Software


2 download

TRANSCRIPT

Page 1: Bootstrap: the full overview
Page 2: Bootstrap: the full overview

Bootstrap: The Full OverviewGill Cleeren - @gillcleeren

Page 3: Bootstrap: the full overview

Hi, I’m Gill!

Gill CleerenMVP and Regional Director.NET Practice Manager @ OrdinaTrainer & speaker

@gillcleeren

[email protected]

Page 4: Bootstrap: the full overview

I’m a Pluralsight author!

• Courses on Windows 8, social and HTML5• http://gicl.me/mypscourses

Page 5: Bootstrap: the full overview

AgendaHello Bootstrap – the 30.000 feet overview

The Grid system

Bootstrap basics

Components

Bootstrap and Forms

Bootstrap and Visual Studio

A little bit of JavaScript

Page 6: Bootstrap: the full overview

Hello BootstrapThe 30.000 feet overview

Page 7: Bootstrap: the full overview

A word about design

• Developers aren’t designers• Often, we don’t have a designer in the project team

• This can be the result…

Page 8: Bootstrap: the full overview
Page 9: Bootstrap: the full overview
Page 10: Bootstrap: the full overview

Looking at sites…

Header

Content

Footer

Page 11: Bootstrap: the full overview
Page 12: Bootstrap: the full overview
Page 13: Bootstrap: the full overview

However…

• Writing CSS isn’t always easy• Cross-browser can be a challenge• Developers want to focus on the non-visual part• Developers loved tables…

Page 14: Bootstrap: the full overview
Page 15: Bootstrap: the full overview

What is Bootstrap?

• Open source• Composed of CSS• And some JavaScript

• Most of the common needs are covered

Page 16: Bootstrap: the full overview

DemoGetBootstrap.com

Page 17: Bootstrap: the full overview

What can Bootstrap do for you?

• Responsive design• Built-in grid system

• Supported (and included) in Visual Studio• Can be themed easily• Create your own• Download a pre-baked theme

• Components• Buttons• Pagination

Page 18: Bootstrap: the full overview

Responsive Layout

Page 19: Bootstrap: the full overview

Responsive Layout

Page 20: Bootstrap: the full overview

Visual Studio – Class IntelliSense

Page 21: Bootstrap: the full overview

Visual Studio – Missing Class Detection

Page 22: Bootstrap: the full overview

DemoVisual Studio & Bootstrap

Page 23: Bootstrap: the full overview

Themes

• Many themes available• Very easy to switch themes• Build a couple of pages• Apply a theme• Easy to switch to another one

• Free and paid

Page 24: Bootstrap: the full overview
Page 25: Bootstrap: the full overview
Page 26: Bootstrap: the full overview

DemoGetting themes in Bootstrap

Page 27: Bootstrap: the full overview

The Bootstrap Grid System

Page 28: Bootstrap: the full overview

It all starts with a container…

• Bootstrap requires a containing element to contain site contents• Grid system will be built from there

• Can be .container or .container-fluid

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

Page 29: Bootstrap: the full overview

The Bootstrap Grid system

• Bootstrap does its layout based on a Grid• Grid always has 12 columns – always

• In fact, you can change it… But why would you?

• Bootstrap comes with 4 grids• Each grid targets a different screen size

• Available grids• Extra small (less than 768px)• Small (768px-991px) • Medium (991px-1200px)• Large (1200px and higher)

Page 30: Bootstrap: the full overview

Available grids in Bootstrap

Extra Small

Small

Large

Medium

Page 31: Bootstrap: the full overview

Grid concepts

• Row & col• Row• Horizontal container (of 12 cols)

• Columns are named• col-<grid size>-<content size>• Example:

• col-lg-8: large, use 8 columns• col-sm-4: small, use 4 columns

• Different classes can be combined • Rows can be nested

<div class="row"> <div class="col-md-6"> </div></div>

<div class="row"> <div class="col-lg-4"> </div></div>

<div class="row"> <div class="col-xs-6"> </div></div>

<div class="row"> <div class="col-sm-6"> </div></div>

Page 32: Bootstrap: the full overview

The Grid in action

col-xx-6 col-xx-6

col-xx-4 col-xx-4 col-xx-4

col-xx-3 col-xx-3 col-xx-6

col-xx-2 col-xx-2 col-xx-2 col-xx-2 col-xx-2 col-xx-2

col-xx-10 col-xx-2

Page 33: Bootstrap: the full overview

Defining columns for 1 grid

<div class="row"> <div class="col-md-8"> <h2>Hello, I want 8 columns please!</h2> </div> <div class="col-md-4"> <h2>I'll take 4 if that's OK...</h2> </div></div>

Page 34: Bootstrap: the full overview

Combining grids

col-lg-6 col-lg-6

col-lg-4 col-md-4 col-sm-4 col-lg-4 col-md-4 col-sm-4 col-lg-4 col-md-4 col-sm-4

col-md-8 col-md-4

Page 35: Bootstrap: the full overview

Combining grids

<div class="row"> <div class="col-md-8 col-xs-8"> <h2>Hello, I want 8 columns please!</h2> </div> <div class="col-md-4 col-xs-4"> <h2>I'll take 4 if that's OK...</h2> </div></div>

Page 36: Bootstrap: the full overview

DemoThe Grid system

Page 37: Bootstrap: the full overview

Offsets in rows

• Offset• Used to leave some cells blank

• Pull• Allows to move an item to the left (pull to left)

• Push• Allows to move an item to the right (push to right)

Page 38: Bootstrap: the full overview

Grid offsets

col-lg-6 col-lg-6

col-xx-4 col-xx-offset-4

col-md-8 col-md-4

Page 39: Bootstrap: the full overview

Grid offsets

<div class="row"> <div class="col-md-4 col-xs-8 col-md-offset-4"> <h2>Hello, I want 8 columns please!</h2> </div> <div class="col-md-4 col-xs-4"> <h2> I'll take 4 if that's OK... </h2> </div></div>

Page 40: Bootstrap: the full overview

Push and pull

<div class="row"> <div class="col-md-8 col-xs-8 col-md-push-4"> <h2>Hello, I'm on the left but want to go to the right!</h2> </div> <div class="col-md-4 col-xs-4 col-md-pull-8"> <h2>I'm on the right but would like to go to the left</h2> </div></div>

Page 41: Bootstrap: the full overview

DemoWorking with offsets, push & pull

Page 42: Bootstrap: the full overview

Playing with visibility

• 2 options• Hidden

• Visible by default• Visible

• Hidden by default

Page 43: Bootstrap: the full overview

Visible and hidden

<div class="row"> <div class="col-md-4 hidden-xs"> <h2>Hello, you can see me!</h2> </div> <div class="col-md-4 col-xs-4 col-md-offset-4"> <h2>I'll always be here...</h2> </div></div>

Page 44: Bootstrap: the full overview

DemoPlaying with visibility

Page 45: Bootstrap: the full overview

Bootstrap basics

Page 46: Bootstrap: the full overview

Bootstrap basics

• Support for • Typography• Code formatting• Tables• Images• Buttons

Page 47: Bootstrap: the full overview

Typography

• Bootstrap uses built-in font• Can be customized

• Headings are supported via <h1> <h6> (or .h1 classes)

<h1>h1. A heading</h1><h2>h2. A smaller heading</h2>

Page 48: Bootstrap: the full overview

Typography

• Also supported• Marked text• Deleted text• Strikethrough text• Inserted text• Underlined text

• Alignment of text• text-left• text-center• text-right

Hi I’m <mark>Mark</mark>.

<del>I’m sadly deleted</del>

<s>Strike!!!</s>

<u>Look, there’s a line below me!</u>

<p class="text-left">Left text.</p><p class="text-center">Center text.</p><p class="text-right">Right text.</p>

Page 49: Bootstrap: the full overview

Typography

• Casing• text-lowercase• text-capitalize

• Lists (ul and ol)• And more…

<p class="text-lowercase">lower.</p><p class="text-uppercase">Upper.</p><p class="text-capitalize">Caps!!!!!.</p>

Page 50: Bootstrap: the full overview

DemoTypography

Page 51: Bootstrap: the full overview

Tables

• Table support (data, not layout)• Available through the .table class

• Typically used for calendars, data tables• List of actors in a movie

• Multiple rows and columns

<table class="table">...</table>

Page 52: Bootstrap: the full overview

Tables

<table class="table"> ...</table>

Page 53: Bootstrap: the full overview

Alternative row colouring

<table class="table table-striped"> ...</table>

Page 54: Bootstrap: the full overview

Other options on table

• Hover (table-hover)• Bordered (table-bordered)• Condensed (table-condensed)• Contextual classes (success, danger…)

• Tables can be made responsive• Horizontal scrollbar on xs• Works through the .table-responsive

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

Page 55: Bootstrap: the full overview

DEMOWorking with tables

Page 56: Bootstrap: the full overview

Buttons

• Classes can be used on a, button and input• Requires btn and type

<a class="btn btn-default" href="#" role="button">Link</a><button class="btn btn-default" type="submit">Button</button><input class="btn btn-default" type="button" value="Input"><input class="btn btn-default" type="submit" value="Submit">

Page 57: Bootstrap: the full overview

Buttons

• More options exist

<button type="button" class="btn btn-success">Success</button>

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

Page 58: Bootstrap: the full overview

Buttons

• Can be sized as well

<button type="button" class="btn btn-default btn-lg">Large</button>

<button type="button" class="btn btn-primary btn-sm">Small</button>

Page 59: Bootstrap: the full overview

Demo

ButtonsDEMO

Page 60: Bootstrap: the full overview

Responsive images

• Images can be made responsive using .img-responsive• Applies max-width: 100%;, height: auto; and display: block; to the image

• Images can also be shaped

<img src="..." class="img-responsive" alt="Responsive image">

<img src="..." alt="..." class="img-rounded"><img src="..." alt="..." class="img-circle"><img src="..." alt="..." class="img-thumbnail">

Page 61: Bootstrap: the full overview

DemoImages

Page 62: Bootstrap: the full overview

Bootstrap components

Page 63: Bootstrap: the full overview

Why would we use Bootstrap components?• Looking good by default• They are “themeable”• Can be replacement for many server-controls

Page 64: Bootstrap: the full overview

Available components

• Glyphicons• Dropdowns• Button groups• Button dropdowns• Input groups• Navs

• Tabs• Pills

• Navbar• Breadcrumbs

• Pagination• Labels• Badges• Jumbotron• Page header• Thumbnails• Alerts• Progress bars• List group• Panels• And a couple more

Page 65: Bootstrap: the full overview

Glyphicons

• Over 250 glyphs in font format• Resolution-independent

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

Page 66: Bootstrap: the full overview

Glyphicons

<button type="button" class="btn btn-default" > <span class="glyphicon glyphicon-align-right" ></span></button>

<button type="button" class="btn btn-default btn-lg"> <span class="glyphicon glyphicon-bell"></span> Bell</button>

Page 67: Bootstrap: the full overview

Dropdowns<div class="dropdown"> <button class="btn btn-default dropdown-toggle" type="button" id="dropdownMenu1" data-toggle="dropdown"> Select a value <span class="caret"></span> </button> <ul class="dropdown-menu" role="menu"> <li role="presentation"><a role="menuitem" tabindex="-1" href="#">1</a></li> <li role="presentation"><a role="menuitem" tabindex="-1" href="#">2</a></li>

... </ul></div>

Page 68: Bootstrap: the full overview

Button groups

<div class="btn-group" role="group"> <button type="button" class="btn btn-default">Option 1</button> <button type="button" class="btn btn-default">Option 2</button> <button type="button" class="btn btn-default">Option 3</button></div>

Page 69: Bootstrap: the full overview

Nav

<ul class="nav nav-tabs"> <li role="presentation" class="active"><a href="#">Home</a></li> <li role="presentation"><a href="#">Profile</a></li> <li role="presentation"><a href="#">Messages</a></li></ul>

Page 70: Bootstrap: the full overview

Pagination <nav> <ul class="pagination"> <li class="disabled"> <a href="#"> <span>&laquo;</span> </a> </li> <li><a href="#">1</a></li> <li><a href="#">2</a></li> ... <li> <a href="#" > <span>&raquo;</span> </a> </li> </ul></nav>

Page 71: Bootstrap: the full overview

Jumbotron

Page 72: Bootstrap: the full overview

Jumbotron

<div class="jumbotron"> <h1>Welcome to Joe's Coffee Store</h1>

<p><a class="btn btn-primary btn-lg" href="#" role="button">See all our coffees</a></p></div>

Page 73: Bootstrap: the full overview

Panels

<div class="panel panel-default"> <div class="panel-heading">Your shopping basket</div> <div class="panel-body"> Basket content goes here </div></div>

Page 74: Bootstrap: the full overview

DEMO: Bootstrap components

Page 75: Bootstrap: the full overview

Bootstrap and Forms

Page 76: Bootstrap: the full overview

Working with forms in Bootstrap

• HTML5 has added more functionality• Many new inputs• Placeholders• Extra arguments

• Bootstrap can be used to enhance functionality• Display forms vertically

• Main classes• form-group• form-control

Page 77: Bootstrap: the full overview

Form example<form> <div class="form-group"> <label for="exampleInputEmail1">Email address</label> <input type="email" class="form-control" id="exampleInputEmail1" ></div> <div class="form-group"> <label for="exampleInputPassword1">Password</label> <input type="password" class="form-control" id="exampleInputPassword1" > </div> <div class="form-group"> <label for="exampleInputFile">File input</label> <input type="file" id="exampleInputFile"> <p class="help-block">All files should be less than 1Mb.</p> </div> <div class="checkbox"> <label> <input type="checkbox"> Public image </label> </div> <button type="submit" class="btn btn-default">Submit</button></form>

Page 78: Bootstrap: the full overview

Result: vertical form

Page 79: Bootstrap: the full overview

Horizontal forms<form class="form-horizontal"> <div class="form-group"> <label for="inputEmail3" class="col-sm-2 control-label">Email</label> <div class="col-sm-10"> <input type="email" class="form-control" id="inputEmail3"> </div> </div> <div class="form-group"> <label for="inputPassword3" class="col-sm-2 control-label">Password</label> <div class="col-sm-10"> <input type="password" class="form-control" id="inputPassword3" > </div> </div> <div class="form-group"> <div class="col-sm-offset-2 col-sm-10"> <button type="submit" class="btn btn-default">Sign in</button> </div> </div></form>

Page 80: Bootstrap: the full overview

Result: horizontal form

Page 81: Bootstrap: the full overview

Available controls in a form

• Regular input types• Text area• Checkboxes• Radio buttons• Selects

• Support for validation statesand icons

Page 82: Bootstrap: the full overview

DemoBootstrap and forms

Page 83: Bootstrap: the full overview

Bootstrap and Visual Studio

Page 84: Bootstrap: the full overview

Bootstrap comes with every web project• WebForms and MVC• CSS• Glyphicons• JavaScript files• Referenced from layout/master files

Page 85: Bootstrap: the full overview

DemoTemplates in Visual Studio

Page 86: Bootstrap: the full overview

VS <3 Bootstrap

• IntelliSense on classes• Missing class detection: enabled via Web Essentials plugin• Bootstrap Snippet pack: extension• Bootstrap bundle (template pack): extension

Page 87: Bootstrap: the full overview

DemoPlugins and extensions in Visual Studio

Page 88: Bootstrap: the full overview

A little bit of JavaScript

Page 89: Bootstrap: the full overview

Bootstrap and JavaScript

• Bootstrap can be enhanced by custom jQuery plugins• Individual JavaScript file per functionality• All at once via bootstrap.js (or bootstrap.min.js)

• jQuery is required• Most functionality is enabled by adding attributes and classes!!• Available extensions• Modal dialogs• Alerts• Dropdowns• Tab

Page 90: Bootstrap: the full overview

Modal dialogs

• Configure dialog using classes• Structure:

• Container: modal• Configure dialog: modal-dialog

• Content: modal-content• Header: modal-header• Content: modal-body• Footer: modal-footer

• Configure launcher using classes• data-toggle="modal"• data-target="<id>"

• Configure closer• data-dismiss="modal"

Page 91: Bootstrap: the full overview

Alerts

• Subtle information• Background task completed• Operation on prior page completed

• Added with classes• alert• alert-type

• Success• Info• Warning• Danger

Page 92: Bootstrap: the full overview

DemoModal dialogs

Let’s write JavaScript!

Yes!

Are you out of your mind?

Page 93: Bootstrap: the full overview

DemoAlerts

Page 94: Bootstrap: the full overview

DEMOCarousel

Page 95: Bootstrap: the full overview

Summary

• Easy to learn• Great results• The way to responsive sites!

Page 96: Bootstrap: the full overview

Thanks!

Page 97: Bootstrap: the full overview

Q&A

Page 98: Bootstrap: the full overview

Bootstrap: The Full OverviewGill Cleeren - @gillcleeren

Page 99: Bootstrap: the full overview

Your feedback is important!Scan the QR Code and let us know via the TechDays App.

Laat ons weten wat u van de sessie vindt via de TechDays App!Scan de QR Code.

Bent u al lid van de Microsoft Virtual Academy?! Op MVA kunt u altijd iets nieuws leren over de laatste technologie van Microsoft. Meld u vandaag aan op de MVA Stand. MVA biedt 7/24 gratis online training on-demand voor IT-Professionals en Ontwikkelaars.