Thursday, August 28, 2014

Dropdown Menus

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>DropDown</title>
<link rel="stylesheet"
href="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<link rel="stylesheet"
href="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css">
<script
src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script
src="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
</style>
</head>
<body>
<div class="dropdown">
<button class="btn btn-default dropdown-toggle" type="button" id="dropdownMenu1" data-toggle="dropdown">
Dropdown <span class="caret"></span>
</button>
<ul class="dropdown-menu" role="menu" aria-labelledby="dropdownMenu1">
<li role="presentation"><a role="menuitem" tabindex="-1" href="#">Action</a></li>
<li role="presentation" class="disabled"><a role="menuitem" tabindex="-1" href="#">Another action</a></li>
<li role="presentation"><a role="menuitem" tabindex="-1" href="#">Something else here</a></li>
<li role="presentation" class="divider"></li>
<li role="presentation"><a role="menuitem" tabindex="-1" href="#">Separated link</a></li>
</ul>
</div>
</body>
</html>

Wednesday, August 27, 2014

Bootstrap CSS

Supported Form Controls

input, textarea, checkbox, radio, and select

input

Bootstrap offers support for all native HTML5 input types:
text, password, datetime, datetime-local, date, month, time, week, number, email, URL, search, tel, and color

<input type="text" placeholder="Text input">
<textarea rows="3"></textarea>




Buttons


Button sizes

If you need larger or smaller buttons, simply add classes .btn-large, .btn-small, or .btnmini to links or buttons

<p>
<button class="btn btn-mini btn-primary" type="button">Mini button</button>
<button class="btn btn-mini" type="button">Mini button</button>
</p>


If you want to create buttons that display like a block-level element, simply add the .btnblock class
These buttons will display at 100% width

<button class="btn btn-large btn-block btn-primary" type="button">Block level button</button>

Disabled Button Styling

For anchor elements, simply add the class of .disabled to the tag and the link will fade in color, and lose the gradient

<a href="#" class="btn btn-large btn-primary disabled">Primary link</a>
<a href="#" class="btn btn-large disabled">Link</a>

You will need to use some JavaScript to actually disable the link

For a button, simply add the disabled attribute to the button, so JavaScript is not directly needed.

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

Images

<img src="..." class="img-rounded">
<img src="..." class="img-circle">
<img src="..." class="img-polaroid">

Icons

Bootstrap bundles 140 icons into one sprite that can be used with buttons, links, navigation, and form fields
The icons are provided by GLYPHICONS

Button groups
<div class="btn-group">
  <button type="button" class="btn btn-default">
<span class="glyphicon glyphicon-star"></span> Star
  </button>
  <button type="button" class="btn btn-default">
<span class="glyphicon glyphicon-heart"></span> Heart
  </button>
  <button type="button" class="btn btn-default">Right</button>
</div>

Navigation

<ul class="nav nav-list">
<li class="active">
<a href="#">
<span class="glyphicon glyphicon-home"></span> Home
</a>
</li>
<li>
<a href="#">
<span class="glyphicon glyphicon-heart"></span> Heart
</a>
</li>
</ul>


Introduction

Bootstrap File Structure

bootstrap/
├── css/
│ ├── bootstrap.css
│ ├── bootstrap.min.css
├── js/
│ ├── bootstrap.js
│ ├── bootstrap.min.js
├── img/
│ ├── glyphicons-halflings.png
│ ├── glyphicons-halflings-white.png
└── README.md

<!DOCTYPE html>
<html>
  <head>
       <title>Bootstrap 101 Template</title>
       <link href="css/bootstrap.min.css" rel="stylesheet">
  </head>
  <body>
       <h1>Hello, world!</h1>
       <script src="js/bootstrap.min.js"></script>
   </body>
</html>

Default Grid System


Basic Grid HTML

spans should add up to 12

<div class="row">
    <div class="span8">...</div>
    <div class="span4">...</div>
</div>

<div class="row">
    <div class="span3">...</div>
    <div class="span5">...</div>
    <div class="span4">...</div>
</div>

Offsetting Columns

<div class="row">
    <div class="span2">...</div>
    <div class="span7 offset2">...</div>
</div>

moves span7 over two columns

Nesting Columns



Fluid Grid System



Container Layouts


Responsive Design

To turn on the responsive features of Bootstrap, you need to add a <meta> tag to the <head> of your web page

<!DOCTYPE html>
<html>
    <head>
        <title>My amazing Bootstrap site!</title>
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <link href="/css/bootstrap.css" rel="stylesheet">
        <link href="/css/bootstrap-responsive.css" rel="stylesheet">
    </head>


Responsive Design

Responsive design is a method for taking all of the existing content that is on the page and optimizing it for the device that is viewing it

Bootstrap uses CSS media queries to measure the width of the browser viewport and then, using conditionals, changes which parts of the stylesheets are loaded


/* Large desktop */
      @media (min-width: 1200px) { ... }
/* Portrait tablet to landscape and desktop */
      @media (min-width: 768px) and (max-width: 979px) { ... }
/* Landscape phone to portrait tablet */
      @media (max-width: 767px) { ... }
/* Landscape phones and down */
      @media (max-width: 480px) { ... }

Helper classes