About bootstrap:
Bootstrap concepts:
- Uses HTML, CSS and Javascript
- front-end framework
- Easy and faster to use and develop
- Responsive design
- Mobile-first approach: In Bootstrap 3, mobile-first styles are part of the core framework
- Browser compatible
Bootstrap concepts:
- Application setup with bootstrap
- Reference to bootstrap
- Download - http://getbootstrap.com
- CDN -
- CSS - http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css
- JavaScript - http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js
- <!DOCTYPE html> at the beginning of the html page
- Mobile first settings - ''
- Width is the width application should take to display
- initial-scale - initial zoom of the page
- Container - bootstrap requires a containing element to wrap site contents. There are two container classes to choose from -
- .container - class provides a responsive fixed width container
- .container-fluid class provides a full width container
- Bootstrap Grid System - grid systems are used for creating page layouts through a series of rows and columns that host application content
- Rows must be placed within a .container class
- Content should be placed within the columns, and only columns may be the immediate children of rows
- Predefined grid classes
- .row
- .col-xs-<#> .col-sm-<#> .col-md-<#> .col-lg-<#> - # could be 1-12
- Multiple column classes can be used to support wide range of devices
- Normalize - bootstrap uses Normalize to establish cross browser consistency in the default styling of HTML elements. Normalize.css is a modern, HTML5-ready alternative to CSS resets. CSS reset is to set styling to html elements to null thus avoiding cross-browser differences as much as possible
- Text emphasis - text-left text-center text-right text-muted text-primary text-success text-info text-warning text-danger.
- List - list-unstyled list-inline.
- Bootstrap tables -
- base table markup - table
- Optional markups - table-striped table-bordered table-hover.(example)
- Contextual classes - active success warning danger. (example)
- The .table-responsive class creates a responsive table. Put this class in a div which holds a table
- Bootstrap form layouts-
- Types
- Vertical (default) form
- In-line form
- Horizontal form
- Rules to follow
- improve accessibility - always use >form role="form"<
- optimum spacing - wrap labels and form controls in >div class="form-group"<
- class .form-control to all textual input, textarea and select elements
- For Horizontal form -
- Add class .form-horizontal to the
- Add class .control-label to all
- Use grid classes to align labels and groups of form controls
- Example - includes all three type of forms
- Alert -
- Create an alert
- Use .alert class in a div
- Followed by one of four contextual classes .alert-success, .alert-info, .alert-warning or .alert-danger.
- To add close functionality
- Add a link or button element in alert div
- add class="close" and data-dismiss="alert".
- Use × (×) HTML entity for close buttons
- Animated alert - add class fade in in alert div.
- Dropdown - (example)
- To create
- Mark a div with class="dropdown".
- Add a button or link to open dropdown menu with "class=dropdown-toggle" and data-target="dropdown".
- Add class="caret" in a span element to show dropdown arrow
- Add class="dropdown-menu".
- Dropdown divider - class="divider" in li element
- Dropdown header- class="dropdown-header" in li element
- Make it accessible to screen readers
- Add role="menu" and aria-labelledby="aName" in ul element
- Add role="presentation" in li element
- Add role="menuitem" in HTML element used inside li
- Panel
- Create with .panel class in a div
- need to define panel-header panel-body panel-footer
- Contextual classes - panel-default panel-success panel-info panel-danger panel-warning panel-primary.
- To group panels - panel-group.
- Collapsible
- On button or link
- Create a div with collapse class
- Create a link or button HTML element with data-toggle="collapse" and data-target="#div_id". This is to show/hide the collapsible div
- On a panel - (example)
- Add button or link in panel header (see above)
- Put panel body and footer in a div with classes panel-collapse collapse.
- Accordion - (example)
- Panel group div should be ided with a name
- Use the data-parent attribute to specify the div id - all collapsible elements under the specified parent will be closed when one of the collapsible item is shown
- Tabs
- Tabs are created with $gt;ul class="nav nav-tabs"<.
- Current page is marked using class="active" in li element
- Use dropdown creation structure in a li which needs to be displayed as dropdown and mark that li with class="dropdown". (example)
- dynamic tabs
- add the data-toggle="tab" attribute to each link
- add a .tab-pane class with a unique ID for every tab
- wrap them inside a div element with class .tab-content.
- Pills - similar concept as tab. Most cases replacing tab with pill will work
- Modal - (example)
- Use a button or a link with attributes:
- data-toggle="modal" opens the modal window
- data-target="#id" points to the id of the modal
- Defining modal
- The parent div of the modal must have an ID, will be used in data-target attribute and .modal class
- The attribute role="dialog" to improve accessibility
- The .modal-dialog class sets the proper width and margin of the modal.
- Defining modal content
- A div with class="modal-content"
- Add the modal's header .modal-header, body .modal-body, and footer .modal-footer.
- To add close feature in header
- Add a button/link inside the header with data-dismiss="modal"
- Add .close class styles the close button
- Add .modal-title class styles the header with a proper line-height.
- Images - below classes need to use in img html element
- img-rounded img-thumnail img-circle img-responsive.
Note:
1. To learn about bootstrap elements which are not mentioned and know more in detail about the elements explained, see the resources
Resources:
1. http://www.w3schools.com/bootstrap/
2. http://www.tutorialspoint.com/bootstrap/
No comments:
Post a Comment