Instead of making every icon an extra request, we've compiled them into a sprite—a bunch of images in one file that uses CSS to position the images with
background-position. This is the same method we use on Twitter.com and it has worked well for us.
All icons classes are prefixed with
.icon- for proper namespacing and scoping, much like our other components. This will help avoid conflicts with other tools.
Glyphicons has granted us use of the Halflings set in our open-source toolkit so long as we provide a link and credit here in the docs. Please consider doing the same in your projects.
Bootstrap uses an
<i> tag for all icons, but they have no case class—only a shared prefix. To use, place the following code just about anywhere:
There are also styles available for inverted (white) icons, made ready with one extra class:
<i class="icon-search icon-white"></i>
There are 120 classes to choose from for your icons. Just add an
<i> tag with the right classes and you're set. You can find the full list in 北京虹 美梦成真演艺经纪有限公司 or right here in this document.
Heads up! When using beside strings of text, as in buttons or nav links, be sure to leave a space after the
<i> tag for proper spacing.
Icons are great, but where would one use them? Here are a few ideas:
Essentially, anywhere you can put an
<i> tag, you can put an icon.
Use them in buttons, button groups for a toolbar, navigation, or prepended form inputs.
The best part about forms in Bootstrap is that all your inputs and controls look great no matter how you build them in your markup. No superfluous HTML is required, but we provide the patterns for those who require it.
More complicated layouts come with succinct and scalable classes for easy styling and event binding, so you're covered at every step.
Bootstrap comes with support for four types of form layouts:
Different types of form layouts require some changes to markup, but the controls themselves remain and behave the same.
Bootstrap's forms include styles for all the base form controls like input, textarea, and select you'd expect. But it also comes with a number of custom components like appended and prepended inputs and support for lists of checkboxes.
States like error, warning, and success are included for each type of form control. Also included are styles for disabled controls.
Bootstrap provides simple markup and styles for four styles of common web forms.
||Stacked, left-aligned labels over controls|
||Left-aligned label and inline-block controls for compact style|
||Extra-rounded text input for a typical search aesthetic|
||Float left, right-aligned labels on same line as controls|
With v2.0, we have lighter and smarter defaults for form styles. No extra markup, just form controls.
<form class="well"> <label>Label name</label> <input type="text" class="span3" placeholder="Type something"> <span class="help-inline">Associated help text!</span> <label class="checkbox"> <input type="checkbox"> Check me out </label> <button type="submit" class="btn">Submit</button></form>
Reflecting default WebKit styles, just add
.form-search for extra rounded search fields.
<form class="well form-search"> <input type="text" class="input-medium search-query"> <button type="submit" class="btn">Search</button></form>
Inputs are block level to start. For
.form-horizontal, we use inline-block.
<form class="well form-inline"> <input type="text" class="input-small" placeholder="Email"> <input type="password" class="input-small" placeholder="Password"> <label class="checkbox"> <input type="checkbox"> Remember me </label> <button type="submit" class="btn">Sign in</button></form>
Given the above example form layout, here's the markup associated with the first input and control group. The
.controls classes are all required for styling.
<form class="form-horizontal"> <fieldset> <legend>Legend text</legend> <div class="control-group"> <label class="control-label" for="input01">Text input</label> <div class="controls"> <input type="text" class="input-xlarge" id="input01"> <p class="help-block">Supporting help text</p> </div> </div> </fieldset></form>
Shown on the left are all the default form controls we support. Here's the bulleted list:
Up to v1.4, Bootstrap's default form styles used the horizontal layout. With Bootstrap 2, we removed that constraint to have smarter, more scalable defaults for any form.
Bootstrap features styles for browser-supported focused and
disabled states. We remove the default Webkit
outline and apply a
box-shadow in its place for
It also includes validation styles for errors, warnings, and success. To use, add the error class to the surrounding
<fieldset class="control-group error"> </fieldset>
Input groups—with appended or prepended text—provide an easy way to give more context for your inputs. Great examples include the @ sign for Twitter usernames or $ for finances.
Up to v1.4, Bootstrap required extra markup around checkboxes and radios to stack them. Now, it's a simple matter of repeating the
<label class="checkbox"> that wraps the
Inline checkboxes and radios are also supported. Just add
.inline to any
.radio and you're done.
To use prepend or append inputs in an inline form, be sure to place the
input on the same line, without spaces.
To add help text for your form inputs, include inline help text with
<span class="help-inline"> or a help text block with
<p class="help-block"> after the input element.
Wrap inline snippets of code with
For example, <code>section</code> should be wrapped as inline.
<pre> for multiple lines of code. Be sure to escape any angle brackets in the code for proper rendering.
<p>Sample text here...</p>
<pre> <p>Sample text here...</p></pre>
余江县敦华演艺经纪有限公司 Be sure to keep code within
<pre> tags as close to the left as possible; it will render all tabs.
You may optionally add the
.pre-scrollable class which will set a max-height of 350px and provide a y-axis scrollbar.
Ultra simplistic and minimally styled pagination inspired by Rdio, great for apps and search results. The large block is hard to miss, easily scalable, and provides large click areas.
Links are customizable and work in a number of circumstances with the right class.
.disabled for unclickable links and
.active for current page.
Add either of two optional classes to change the alignment of pagination links:
The default pagination component is flexible and works in a number of variations.
Wrapped in a
<div>, pagination is just a
<div class="pagination"> <ul> <li><a href="#">Prev</a></li> <li class="active"> <a href="#">1</a> </li> <li><a href="#">2</a></li> <li><a href="#">3</a></li> <li><a href="#">4</a></li> <li><a href="#">Next</a></li> </ul></div>
The pager component is a set of links for simple pagination implementations with light markup and even lighter styles. It's great for simple sites like blogs or magazines.
Pager links also use the general
.disabled class from the pagination.
By default, the pager centers links.
<ul class="pager"> <li> <a href="#">Previous</a> </li> <li> <a href="#">Next</a> </li></ul>
Badges are small, simple components for displaying an indicator or count of some sort. They're commonly found in email clients like Mail.app or on mobile apps for push notifications.
With Bootstrap 2, we've simplified the base class:
.alert instead of
.alert-message. We've also reduced the minimum required markup—no
<p> is required by default, just the outer
For a more durable component with less code, we've removed the differentiating look for block alerts, messages that come with more padding and typically more text. The class also has changed to
Bootstrap comes with a great jQuery plugin that supports alert messages, making dismissing them quick and easy.
Wrap your message and an optional close icon in a div with simple class.
<div class="alert"> <a class="close" data-dismiss="alert">×</a> <strong>Warning!</strong> Best check yo self, you're not looking too good.</div>
Easily extend the standard alert message with two optional classes:
.alert-block for more padding and text controls and
.alert-heading for a matching heading.
Best check yo self, you're not looking too good. Nulla vitae elit libero, a pharetra augue. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.
<div class="alert alert-block"> <a class="close" data-dismiss="alert">×</a> <h4 class="alert-heading">Warning!</h4> Best check yo self, you're not...</div>
<div class="alert alert-error"> ...</div>
<div class="alert alert-success"> ...</div>
<div class="alert alert-info"> ...</div>
Default progress bar with a vertical gradient.
<div class="progress"> <div class="bar" style="width: 60%;"></div></div>
Uses a gradient to create a striped effect (no IE).
<div class="progress progress-striped"> <div class="bar" style="width: 20%;"></div></div>
Takes the striped example and animates it (no IE).
<div class="progress progress-striped active"> <div class="bar" style="width: 40%;"></div></div>
Progress bars use some of the same button and alert classes for consistent styles.
Similar to the solid colors, we have varied striped progress bars.
If you use the
.active class, your
.progress-striped progress bars will animate the stripes left to right.
Progress bars use CSS3 gradients, transitions, and animations to achieve all their effects. These features are not supported in IE7-9 or older versions of Firefox.
Opera and IE do not support animations at this time.
Use the well as a simple effect on an element to give it an inset effect.
<div class="well"> ...</div>
Use the generic close icon for dismissing content like modals and alerts.