diff --git a/dist/js/bootstrap.js b/dist/js/bootstrap.js index e389c19604..5f95f74e8e 100644 --- a/dist/js/bootstrap.js +++ b/dist/js/bootstrap.js @@ -1054,7 +1054,7 @@ if (typeof jQuery === 'undefined') { throw new Error('Bootstrap\'s JavaScript re animation: true, placement: 'top', selector: false, - template: '
Provide contextual feedback messages for typical user actions with the handful of available and flexible alert messages. For inline dismissal, use the alerts jQuery plugin.
+ +Wrap any text and an optional dismiss button in .alert
and one of the four contextual classes (e.g., .alert-success
) for basic alert messages.
Alerts don't have default classes, only base and modifier classes. A default gray alert doesn't make too much sense, so you're required to specify a type via contextual class. Choose from success, info, warning, or danger.
+Build on any alert by adding an optional .alert-dismissable
and close button.
Be sure to use the <button>
element with the data-dismiss="alert"
data attribute.
Use the .alert-link
utility class to quickly provide matching colored links within any alert.
Easily highlight new or unread items by adding a <span class="badge">
to links, Bootstrap navs, and more.
When there are no new or unread items, badges will simply collapse (via CSS's :empty
selector) provided no content exists within.
Badges won't self collapse in Internet Explorer 8 because it lacks support for the :empty
selector.
Built-in styles are included for placing badges in active states in pill navigations.
+Indicate the current page's location within a navigational hierarchy.
+Separators are automatically added in CSS through :before
and content
.
Use any button to trigger a dropdown menu by placing it within a .btn-group
and providing the proper menu markup.
Button dropdowns require the dropdown plugin to be included in your version of Bootstrap.
+Turn a button into a dropdown toggle with some basic markup changes.
+Similarly, create split button dropdowns with the same markup changes, only with a separate button.
+Button dropdowns work with buttons of all sizes.
+Trigger dropdown menus above elements by adding .dropup
to the parent.
Group a series of buttons together on a single line with the button group. Add on optional JavaScript radio and checkbox style behavior with our buttons plugin.
+ +When using tooltips or popovers on elements within a .btn-group
, you'll have to specify the option container: 'body'
to avoid unwanted side effects (such as the element growing wider and/or losing its rounded corners when the tooltip or popover is triggered).
Wrap a series of buttons with .btn
in .btn-group
.
Combine sets of <div class="btn-group">
into a <div class="btn-toolbar">
for more complex components.
Instead of applying button sizing classes to every button in a group, just add .btn-group-*
to the .btn-group
.
Place a .btn-group
within another .btn-group
when you want dropdown menus mixed with a series of buttons.
Make a set of buttons appear vertically stacked rather than horizontally. Split button dropdowns are not supported here.
+Make a group of buttons stretch at equal sizes to span the entire width of its parent. Also works with button dropdowns within the button group.
+ +Due to the specific HTML and CSS used to justify buttons (namely display: table-cell
), the borders between them are doubled. In regular button groups, margin-left: -1px
is used to stack the borders instead of removing them. However, margin
doesn't work with display: table-cell
. As a result, depending on your customizations to Bootstrap, you may wish to remove or re-color the borders.
Internet Explorer 8 doesn't render borders in on buttons in a justified button group, whether it's on <a>
or <button>
elements. To get around that, wrap each button in another .btn-group
.
See #12476 for more information.
+<a>
elementsJust wrap a series of .btn
s in .btn-group.btn-group-justified
.
<button>
elementsTo use justified button groups with <button>
elements, you must wrap each button in a button group. Most browsers don't properly apply our CSS for justification to <button>
elements, but since we support button dropdowns, we can workaround that.
Toggleable, contextual menu for displaying lists of links. Made interactive with the dropdown JavaScript plugin.
+ +Wrap the dropdown's trigger and the dropdown menu within .dropdown
, or another element that declares position: relative;
. Then add the menu's HTML.
By default, a dropdown menu is automatically positioned 100% from the top and along the left side of its parent. Add .dropdown-menu-right
to a .dropdown-menu
to right align the dropdown menu.
Dropdowns are automatically positioned via CSS within the normal flow of the document. This means dropdowns may be cropped by parents with certain overflow
properties or appear out of bounds of the viewport. Address these issues on your own as they arise.
.pull-right
alignmentAs of v3.1.0, we've deprecated .pull-right
on dropdown menus. To right-align a menu, use .dropdown-menu-right
. Right-aligned nav components in the navbar use a mixin version of this class to automatically align the menu. To override it, use .dropdown-menu-left
.
Add a header to label sections of actions in any dropdown menu.
+Add .disabled
to a <li>
in the dropdown to disable the link.
Includes 200 glyphs in font format from the Glyphicon Halflings set. Glyphicons Halflings are normally not available for free, but their creator has made them available for Bootstrap free of cost. As a thank you, we only ask that you include a link back to Glyphicons whenever possible.
+For performance reasons, all icons require a base class and individual icon class. To use, place the following code just about anywhere. Be sure to leave a space between the icon and text for proper padding.
+Icon classes cannot be directly combined with other components. They should not be used along with other classes on the same element. Instead, add a nested <span>
and apply the icon classes to the <span>
.
Use them in buttons, button groups for a toolbar, navigation, or prepended form inputs.
+Extend form controls by adding text or buttons before, after, or on both sides of any text-based input. Use .input-group
with an .input-group-addon
to prepend or append elements to a single .form-control
.
Avoid using <select>
elements here as they cannot be fully styled in WebKit browsers.
When using tooltips or popovers on elements within an .input-group
, you'll have to specify the option container: 'body'
to avoid unwanted side effects (such as the element growing wider and/or losing its rounded corners when the tooltip or popover is triggered).
Do not mix form groups or grid column classes directly with input groups. Instead, nest the input group inside of the form group or grid-related element.
+Place one add-on or button on either side of an input. You may also place one on both sides of an input.
+We do not support multiple add-ons on a single side.
+We do not support multiple form-controls in a single input group.
+ +{% highlight html %} +Add the relative form sizing classes to the .input-group
itself and contents within will automatically resize—no need for repeating the form control size classes on each element.
Place any checkbox or radio option within an input group's addon instead of text.
+ +{% highlight html %} +Buttons in input groups are a bit different and require one extra level of nesting. Instead of .input-group-addon
, you'll need to use .input-group-btn
to wrap the buttons. This is required due to default browser styles that cannot be overridden.
A lightweight, flexible component that can optionally extend the entire viewport to showcase key content on your site.
+This is a simple hero unit, a simple jumbotron-style component for calling extra attention to featured content or information.
+ +To make the jumbotron full width, and without rounded corners, place it outside all .container
s and instead add a .container
within.
Add any of the below mentioned modifier classes to change the appearance of a label.
+List groups are a flexible and powerful component for displaying not only simple lists of elements, but complex ones with custom content.
+ +The most basic list group is simply an unordered list with list items, and the proper classes. Build upon it with the options that follow, or your own CSS as needed.
+Add the badges component to any list group item and it will automatically be positioned on the right.
+Linkify list group items by using anchor tags instead of list items (that also means a parent <div>
instead of an <ul>
). No need for individual parents around each element.
Add .disabled
to a .list-group-item
to gray it out to appear disabled.
Use contextual classes to style list items, default or linked. Also includes .active
state.
Add nearly any HTML within, even for linked list groups like the one below.
+Donec id elit non mi porta gravida at eget metus. Maecenas sed diam eget risus varius blandit.
+ + +Donec id elit non mi porta gravida at eget metus. Maecenas sed diam eget risus varius blandit.
+ + +Donec id elit non mi porta gravida at eget metus. Maecenas sed diam eget risus varius blandit.
+ +Abstract object styles for building various types of components (like blog comments, Tweets, etc) that feature a left- or right-aligned image alongside textual content.
+ +The default media allow to float a media object (images, video, audio) to the left or right of a content block.
+With a bit of extra markup, you can use media inside list (useful for comment threads or articles lists).
+Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin commodo. Cras purus odio, vestibulum in vulputate at, tempus viverra turpis.
+ +Navbars are responsive meta components that serve as navigation headers for your application or site. They begin collapsed (and are toggleable) in mobile views and become horizontal as the available viewport width increases.
+ + +If JavaScript is disabled and the viewport is narrow enough that the navbar collapses, it will be impossible to expand the navbar and view the content within the .navbar-collapse
.
The responsive navbar requires the collapse plugin to be included in your version of Bootstrap.
+Be sure to add a role="navigation"
to every navbar to help with accessibility.
Place form content within .navbar-form
for proper vertical alignment and collapsed behavior in narrow viewports. Use the alignment options to decide where it resides within the navbar content.
As a heads up, .navbar-form
shares much of its code with .form-inline
via mixin. Some form controls, like input groups, may require fixed widths to be show up properly within a navbar.
There are some caveats regarding using form controls within fixed elements on mobile devices. See our browser support docs for details.
+Screen readers will have trouble with your forms if you don't include a label for every input. For these inline navbar forms, you can hide the labels using the .sr-only
class.
Add the .navbar-btn
class to <button>
elements not residing in a <form>
to vertically center them in the navbar.
Like the standard button classes, .navbar-btn
can be used on <a>
and <input>
elements. However, neither .navbar-btn
nor the standard button classes should be used on <a>
elements within .navbar-nav
.
Wrap strings of text in an element with .navbar-text
, usually on a <p>
tag for proper leading and color.
For folks using standard links that are not within the regular navbar navigation component, use the .navbar-link
class to add the proper colors for the default and inverse navbar options.
Align nav links, forms, buttons, or text, using the .navbar-left
or .navbar-right
utility classes. Both classes will add a CSS float in the specified direction. For example, to align nav links, put them in a separate <ul>
with the respective utility class applied.
These classes are mixin-ed versions of .pull-left
and .pull-right
, but they're scoped to media queries for easier handling of navbar components across device sizes.
Navbars currently have a limitation with multiple .navbar-right
classes. To properly space content, we use negative margin on the last .navbar-right
element. When there are multiple elements using that class, these margins don't work as intended.
We'll revisit this when we can rewrite that component in v4.
+Add .navbar-fixed-top
and include a .container
or .container-fluid
to center and pad navbar content.
The fixed navbar will overlay your other content, unless you add padding
to the top of the <body>
. Try out your own values or use our snippet below. Tip: By default, the navbar is 50px high.
Make sure to include this after the core Bootstrap CSS.
+Add .navbar-fixed-bottom
and include a .container
or .container-fluid
to center and pad navbar content.
The fixed navbar will overlay your other content, unless you add padding
to the bottom of the <body>
. Try out your own values or use our snippet below. Tip: By default, the navbar is 50px high.
Make sure to include this after the core Bootstrap CSS.
+Create a full-width navbar that scrolls away with the page by adding .navbar-static-top
and include a .container
or .container-fluid
to center and pad navbar content.
Unlike the .navbar-fixed-*
classes, you do not need to change any padding on the body
.
Modify the look of the navbar by adding .navbar-inverse
.
Navs available in Bootstrap have shared markup, starting with the base .nav
class, as well as shared states. Swap modifier classes to switch between each style.
Note the .nav-tabs
class requires the .nav
base class.
For tabs with tabbable areas, you must use the tabs JavaScript plugin.
+Take that same HTML, but use .nav-pills
instead:
Pills are also vertically stackable. Just add .nav-stacked
.
Easily make tabs or pills equal widths of their parent at screens wider than 768px with .nav-justified
. On smaller screens, the nav links are stacked.
As of v7.0.1, Safari exhibits a bug in which resizing your browser horizontally causes rendering errors in the justified nav that are cleared upon refreshing. This bug is also shown in the justified nav example.
+For any nav component (tabs or pills), add .disabled
for gray links and no hover effects.
This class will only change the <a>
's appearance, not its functionality. Use custom JavaScript to disable links here.
Add dropdown menus with a little extra HTML and the dropdowns JavaScript plugin.
+ +A simple shell for an h1
to appropriately space out and segment sections of content on a page. It can utilize the h1
's default small
element, as well as most other components (with additional styles).
Provide pagination links for your site or app with the multi-page pagination component, or the simpler pager alternative.
+ +Simple pagination inspired by Rdio, great for apps and search results. The large block is hard to miss, easily scalable, and provides large click areas.
+ +{% highlight html %} + +{% endhighlight %} + +Links are customizable for different circumstances. Use .disabled
for unclickable links and .active
to indicate the current page.
You can optionally swap out active or disabled anchors for <span>
to remove click functionality while retaining intended styles.
Fancy larger or smaller pagination? Add .pagination-lg
or .pagination-sm
for additional sizes.
Quick previous and next links for simple pagination implementations with light markup and styles. It's great for simple sites like blogs or magazines.
+ +By default, the pager centers links.
+ +{% highlight html %} + +{% endhighlight %} + +Alternatively, you can align each link to the sides:
+ +{% highlight html %} + +{% endhighlight %} + + +Pager links also use the general .disabled
utility class from the pagination.
While not always necessary, sometimes you need to put your DOM in a box. For those situations, try the panel component.
+ +By default, all the .panel
does is apply some basic border and padding to contain some content.
Easily add a heading container to your panel with .panel-heading
. You may also include any <h1>
-<h6>
with a .panel-title
class to add a pre-styled heading.
Wrap buttons or secondary text in .panel-footer
. Note that panel footers do not inherit colors and borders when using contextual variations as they are not meant to be in the foreground.
Like other components, easily make a panel more meaningful to a particular context by adding any of the contextual state classes.
+Add any non-bordered .table
within a panel for a seamless design. If there is a .panel-body
, we add an extra border to the top of the table for separation.
Some default panel content here. Nulla vitae elit libero, a pharetra augue. Aenean lacinia bibendum nulla sed consectetur. Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum. Nullam id dolor id nibh ultricies vehicula ut id elit.
+# | +First Name | +Last Name | +Username | +
---|---|---|---|
1 | +Mark | +Otto | +@mdo | +
2 | +Jacob | +Thornton | +@fat | +
3 | +Larry | +the Bird | +
...
+If there is no panel body, the component moves from panel header to table without interruption.
+# | +First Name | +Last Name | +Username | +
---|---|---|---|
1 | +Mark | +Otto | +@mdo | +
2 | +Jacob | +Thornton | +@fat | +
3 | +Larry | +the Bird | +
Easily include full-width list groups within any panel.
+Some default panel content here. Nulla vitae elit libero, a pharetra augue. Aenean lacinia bibendum nulla sed consectetur. Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum. Nullam id dolor id nibh ultricies vehicula ut id elit.
+...
+Provide up-to-date feedback on the progress of a workflow or action with simple yet flexible progress bars.
+ +Progress bars use CSS3 transitions and animations to achieve some of their effects. These features are not supported in Internet Explorer 9 and below or older versions of Firefox. Opera 12 does not support animations.
+Default progress bar.
+Remove the .sr-only
class from within the progress bar to show a visible percentage. For low percentages, consider adding a min-width
to ensure the label's text is fully visible.
Progress bars representing low single digit percentages, as well as 0%, include a min-width: 20px;
for legibility.
Progress bars use some of the same button and alert classes for consistent styles.
+Uses a gradient to create a striped effect. Not available in IE8.
+Add .active
to .progress-striped
to animate the stripes right to left. Not available in IE9 and below.
Place multiple bars into the same .progress
to stack them.
Allow browsers to determine video or slideshow dimensions based on the width of their containing block by creating an intrinsic ratio that will properly scale on any device.
+Rules are directly apply to <iframe>
, <embed>
and <object>
elements, optionally use of an explicit descendant class .embed-responsive-item
when you want to match the styling for other attributes.
Pro-Tip! You don't need to include frameborder="0"
in your <iframe>
s as we override that for you.
Extend Bootstrap's grid system with the thumbnail component to easily display grids of images, videos, text, and more.
+ +By default, Bootstrap's thumbnails are designed to showcase linked images with minimal required markup.
+ +{% highlight html %} +With a bit of extra markup, it's possible to add any kind of HTML content like headings, paragraphs, or buttons into thumbnails.
+Use the well as a simple effect on an element to give it an inset effect.
+Control padding and rounded corners with two optional modifier classes.
+Use any of the available button classes to quickly create a styled button.
+Fancy larger or smaller buttons? Add .btn-lg
, .btn-sm
, or .btn-xs
for additional sizes.
+ + +
++ + +
++ + +
++ + +
++ + +
++ + +
++ + +
++ + +
+{% endhighlight %} + +Create block level buttons—those that span the full width of a parent— by adding .btn-block
.
Buttons will appear pressed (with a darker background, darker border, and inset shadow) when active. For <button>
elements, this is done via :active
. For <a>
elements, it's done with .active
. However, you may use .active
on <button>
s should you need to replicate the active state progammatically.
No need to add :active
as it's a pseudo-class, but if you need to force the same appearance, go ahead and add .active
.
+ + +
+{% highlight html %} + + +{% endhighlight %} + +Add the .active
class to <a>
buttons.
+ Primary link + Link +
+{% highlight html %} +Primary link +Link +{% endhighlight %} + + +Make buttons look unclickable by fading them back 50%.
+ +Add the disabled
attribute to <button>
buttons.
+ + +
+{% highlight html %} + + +{% endhighlight %} + +If you add the disabled
attribute to a <button>
, Internet Explorer 9 and below will render text gray with a nasty text-shadow that we cannot fix.
Add the .disabled
class to <a>
buttons.
+ Primary link + Link +
+{% highlight html %} +Primary link +Link +{% endhighlight %} +
+ We use .disabled
as a utility class here, similar to the common .active
class, so no prefix is required.
+
This class uses pointer-events: none
to try to disable the link functionality of <a>
s, but that CSS property is not yet standardized and isn't fully supported in Opera 18 and below, or in Internet Explorer 11. So to be safe, use custom JavaScript to disable such links.
While button classes can be used on <a>
and <button>
elements, only <button>
elements are supported within our nav and navbar components.
Use the button classes on an <a>
, <button>
, or <input>
element.
As a best practice, we highly recommend using the <button>
element whenever possible to ensure matching cross-browser rendering.
Among other things, there's a Firefox bug that prevents us from setting the line-height
of <input>
-based buttons, causing them to not exactly match the height of other buttons on Firefox.
Wrap inline snippets of code with <code>
.
<section>
should be wrapped as inline.
+<section>
should be wrapped as inline.
+{% endhighlight %}
+
+ Use the <kbd>
to indicate input that is typically entered via keyboard.
Use <pre>
for multiple lines of code. Be sure to escape any angle brackets in the code for proper rendering.
<p>Sample text here...</p>+
<p>Sample text here...</p>+{% endhighlight %} + +
You may optionally add the .pre-scrollable
class, which will set a max-height of 350px and provide a y-axis scrollbar.
For indicating variables use the <var>
tag.
y = mx + b
+ +For indicating blocks sample output from a program use the <samp>
tag.
This text is meant to be treated as sample output from a computer program.
+Individual form controls automatically receive some global styling. All textual <input>
, <textarea>
, and <select>
elements with .form-control
are set to width: 100%;
by default. Wrap labels and controls in .form-group
for optimum spacing.
Do not mix form groups directly with input groups. Instead, nest the input group inside of the form group.
+Add .form-inline
to your <form>
for left-aligned and inline-block controls. This only applies to forms within viewports that are at least 768px wide.
Inputs, selects, and textareas are 100% wide by default in Bootstrap. To use the inline form, you'll have to set a width on the form controls used within.
+Screen readers will have trouble with your forms if you don't include a label for every input. For these inline forms, you can hide the labels using the .sr-only
class.
Use Bootstrap's predefined grid classes to align labels and groups of form controls in a horizontal layout by adding .form-horizontal
to the form. Doing so changes .form-group
s to behave as grid rows, so no need for .row
.
Examples of standard form controls supported in an example form layout.
+ +Most common form control, text-based input fields. Includes support for all HTML5 types: text
, password
, datetime
, datetime-local
, date
, month
, time
, week
, number
, email
, url
, search
, tel
, and color
.
Inputs will only be fully styled if their type
is properly declared.
To add integrated text or buttons before and/or after any text-based <input>
, check out the input group component.
Form control which supports multiple lines of text. Change rows
attribute as necessary.
Checkboxes are for selecting one or several options in a list while radios are for selecting one option from many.
+Use the .checkbox-inline
or .radio-inline
classes on a series of checkboxes or radios for controls that appear on the same line.
Use the default option, or add multiple
to show multiple options at once.
When you need to place plain text next to a form label within a horizontal form, use the .form-control-static
class on a <p>
.
We remove the default outline
styles on some form controls and apply a box-shadow
in its place for :focus
.
:focus
stateThe above example input uses custom styles in our documentation to demonstrate the :focus
state on a .form-control
.
Add the disabled
boolean attribute on an input to prevent user input and trigger a slightly different look.
Add the disabled
attribute to a <fieldset>
to disable all the controls within the <fieldset>
at once.
<a>
Our styles use pointer-events: none
to try to disable the link functionality of <a class="btn btn-*">
buttons in this case, but that CSS property is not yet standardized and isn't fully supported in Opera 18 and below, or in Internet Explorer 11. So to be safe, use custom JavaScript to disable such links.
While Bootstrap will apply these styles in all browsers, Internet Explorer 9 and below don't actually support the disabled
attribute on a <fieldset>
. Use custom JavaScript to disable the fieldset in these browsers.
Add the readonly
boolean attribute on an input to prevent user input and style the input as disabled.
Bootstrap includes validation styles for error, warning, and success states on form controls. To use, add .has-warning
, .has-error
, or .has-success
to the parent element. Any .control-label
, .form-control
, and .help-block
within that element will receive the validation styles.
You can also add optional feedback icons with the addition of .has-feedback
and the right icon.
Manual positioning of feedback icons is required for inputs without a label and for input groups with an add-on on the right. For inputs without labels, adjust the top
value. For input groups, adjust the right
value to an appropriate pixel value depending on the width of your addon.
Optional icons also work on horizontal and inline forms.
+Set heights using classes like .input-lg
, and set widths using grid column classes like .col-lg-*
.
Create taller or shorter form controls that match button sizes.
+Wrap inputs in grid columns, or any custom parent element, to easily enforce desired widths.
+Block level help text for form controls.
+Bootstrap includes a responsive, mobile first fluid grid system that appropriately scales up to 12 columns as the device or viewport size increases. It includes predefined classes for easy layout options, as well as powerful mixins for generating more semantic layouts.
+ +Grid systems are used for creating page layouts through a series of rows and columns that house your content. Here's how the Bootstrap grid system works:
+.container
(fixed-width) or .container-fluid
(full-width) for proper alignment and padding..row
and .col-xs-4
are available for quickly making grid layouts. Less mixins can also be used for more semantic layouts.padding
. That padding is offset in rows for the first and last column via negative margin on .row
s..col-xs-4
..col-md-
class to an element will not only affect its styling on medium devices but also on large devices if a .col-lg-
class is not present.Look to the examples for applying these principles to your code.
+ +We use the following media queries in our Less files to create the key breakpoints in our grid system.
+{% highlight scss %} +/* Extra small devices (phones, less than 768px) */ +/* No media query since this is the default in Bootstrap */ + +/* Small devices (tablets, 768px and up) */ +@media (min-width: @screen-sm-min) { ... } + +/* Medium devices (desktops, 992px and up) */ +@media (min-width: @screen-md-min) { ... } + +/* Large devices (large desktops, 1200px and up) */ +@media (min-width: @screen-lg-min) { ... } +{% endhighlight %} +We occasionally expand on these media queries to include a max-width
to limit CSS to a narrower set of devices.
See how aspects of the Bootstrap grid system work across multiple devices with a handy table.
++ | + Extra small devices + Phones (<768px) + | ++ Small devices + Tablets (≥768px) + | ++ Medium devices + Desktops (≥992px) + | ++ Large devices + Desktops (≥1200px) + | +
---|---|---|---|---|
Grid behavior | +Horizontal at all times | +Collapsed to start, horizontal above breakpoints | +||
Container width | +None (auto) | +750px | +970px | +1170px | +
Class prefix | +.col-xs- |
+ .col-sm- |
+ .col-md- |
+ .col-lg- |
+
# of columns | +12 | +|||
Column width | +Auto | +~62px | +~81px | +~97px | +
Gutter width | +30px (15px on each side of a column) | +|||
Nestable | +Yes | +|||
Offsets | +Yes | +|||
Column ordering | +Yes | +
Using a single set of .col-md-*
grid classes, you can create a basic grid system that starts out stacked on mobile devices and tablet devices (the extra small to small range) before becoming horizontal on desktop (medium) devices. Place grid columns in any .row
.
Turn any fixed-width grid layout into a full-width layout by changing your outermost .container
to .container-fluid
.
Don't want your columns to simply stack in smaller devices? Use the extra small and medium device grid classes by adding .col-xs-*
.col-md-*
to your columns. See the example below for a better idea of how it all works.
Build on the previous example by creating even more dynamic and powerful layouts with tablet .col-sm-*
classes.
With the four tiers of grids available you're bound to run into issues where, at certain breakpoints, your columns don't clear quite right as one is taller than the other. To fix that, use a combination of a .clearfix
and our responsive utility classes.
In addition to column clearing at responsive breakpoints, you may need to reset offsets, pushes, or pulls. See this in action in the grid example.
+{% highlight html %} +Move columns to the right using .col-md-offset-*
classes. These classes increase the left margin of a column by *
columns. For example, .col-md-offset-4
moves .col-md-4
over four columns.
To nest your content with the default grid, add a new .row
and set of .col-md-*
columns within an existing .col-md-*
column. Nested rows should include a set of columns that add up to 12 or less.
Easily change the order of our built-in grid columns with .col-md-push-*
and .col-md-pull-*
modifier classes.
In addition to prebuilt grid classes for fast layouts, Bootstrap includes Less variables and mixins for quickly generating your own simple, semantic layouts.
+ +Variables determine the number of columns, the gutter width, and the media query point at which to begin floating columns. We use these to generate the predefined grid classes documented above, as well as for the custom mixins listed below.
+{% highlight scss %} +@grid-columns: 12; +@grid-gutter-width: 30px; +@grid-float-breakpoint: 768px; +{% endhighlight %} + +Mixins are used in conjunction with the grid variables to generate semantic CSS for individual grid columns.
+{% highlight scss %} +// Creates a wrapper for a series of columns +.make-row(@gutter: @grid-gutter-width) { + // Then clear the floated columns + .clearfix(); + + @media (min-width: @screen-sm-min) { + margin-left: (@gutter / -2); + margin-right: (@gutter / -2); + } + + // Negative margin nested rows out to align the content of columns + .row { + margin-left: (@gutter / -2); + margin-right: (@gutter / -2); + } +} + +// Generate the extra small columns +.make-xs-column(@columns; @gutter: @grid-gutter-width) { + position: relative; + // Prevent columns from collapsing when empty + min-height: 1px; + // Inner gutter via padding + padding-left: (@gutter / 2); + padding-right: (@gutter / 2); + + // Calculate width based on number of columns available + @media (min-width: @grid-float-breakpoint) { + float: left; + width: percentage((@columns / @grid-columns)); + } +} + +// Generate the small columns +.make-sm-column(@columns; @gutter: @grid-gutter-width) { + position: relative; + // Prevent columns from collapsing when empty + min-height: 1px; + // Inner gutter via padding + padding-left: (@gutter / 2); + padding-right: (@gutter / 2); + + // Calculate width based on number of columns available + @media (min-width: @screen-sm-min) { + float: left; + width: percentage((@columns / @grid-columns)); + } +} + +// Generate the small column offsets +.make-sm-column-offset(@columns) { + @media (min-width: @screen-sm-min) { + margin-left: percentage((@columns / @grid-columns)); + } +} +.make-sm-column-push(@columns) { + @media (min-width: @screen-sm-min) { + left: percentage((@columns / @grid-columns)); + } +} +.make-sm-column-pull(@columns) { + @media (min-width: @screen-sm-min) { + right: percentage((@columns / @grid-columns)); + } +} + +// Generate the medium columns +.make-md-column(@columns; @gutter: @grid-gutter-width) { + position: relative; + // Prevent columns from collapsing when empty + min-height: 1px; + // Inner gutter via padding + padding-left: (@gutter / 2); + padding-right: (@gutter / 2); + + // Calculate width based on number of columns available + @media (min-width: @screen-md-min) { + float: left; + width: percentage((@columns / @grid-columns)); + } +} + +// Generate the medium column offsets +.make-md-column-offset(@columns) { + @media (min-width: @screen-md-min) { + margin-left: percentage((@columns / @grid-columns)); + } +} +.make-md-column-push(@columns) { + @media (min-width: @screen-md-min) { + left: percentage((@columns / @grid-columns)); + } +} +.make-md-column-pull(@columns) { + @media (min-width: @screen-md-min) { + right: percentage((@columns / @grid-columns)); + } +} + +// Generate the large columns +.make-lg-column(@columns; @gutter: @grid-gutter-width) { + position: relative; + // Prevent columns from collapsing when empty + min-height: 1px; + // Inner gutter via padding + padding-left: (@gutter / 2); + padding-right: (@gutter / 2); + + // Calculate width based on number of columns available + @media (min-width: @screen-lg-min) { + float: left; + width: percentage((@columns / @grid-columns)); + } +} + +// Generate the large column offsets +.make-lg-column-offset(@columns) { + @media (min-width: @screen-lg-min) { + margin-left: percentage((@columns / @grid-columns)); + } +} +.make-lg-column-push(@columns) { + @media (min-width: @screen-lg-min) { + left: percentage((@columns / @grid-columns)); + } +} +.make-lg-column-pull(@columns) { + @media (min-width: @screen-lg-min) { + right: percentage((@columns / @grid-columns)); + } +} +{% endhighlight %} + +You can modify the variables to your own custom values, or just use the mixins with their default values. Here's an example of using the default settings to create a two-column layout with a gap between.
+{% highlight scss %} +.wrapper { + .make-row(); +} +.content-main { + .make-lg-column(8); +} +.content-secondary { + .make-lg-column(3); + .make-lg-column-offset(1); +} +{% endhighlight %} +{% highlight html %} +Convey meaning through color with a handful of emphasis utility classes. These may also be applied to links and will darken on hover just like our default link styles.
+Fusce dapibus, tellus ac cursus commodo, tortor mauris nibh.
+Nullam id dolor id nibh ultricies vehicula ut id elit.
+Duis mollis, est non commodo luctus, nisi erat porttitor ligula.
+Maecenas sed diam eget risus varius blandit sit amet non magna.
+Etiam porta sem malesuada magna mollis euismod.
+Donec ullamcorper nulla non metus auctor fringilla.
+...
+...
+...
+...
+...
+...
+{% endhighlight %} +Sometimes emphasis classes cannot be applied due to the specificity of another selector. In most cases, a sufficient workaround is to wrap your text in a <span>
with the class.
Similar to the contextual text color classes, easily set the background of an element to any contextual class. Anchor components will darken on hover, just like the text classes.
+Nullam id dolor id nibh ultricies vehicula ut id elit.
+Duis mollis, est non commodo luctus, nisi erat porttitor ligula.
+Maecenas sed diam eget risus varius blandit sit amet non magna.
+Etiam porta sem malesuada magna mollis euismod.
+Donec ullamcorper nulla non metus auctor fringilla.
+...
+...
+...
+...
+...
+{% endhighlight %} + + +Use the generic close icon for dismissing content like modals and alerts.
+Use carets to indicate dropdown functionality and direction. Note that the default caret will reverse automatically in dropup menus.
+Float an element to the left or right with a class. !important
is included to avoid specificity issues. Classes can also be used as mixins.
To align components in navbars with utility classes, use .navbar-left
or .navbar-right
instead. See the navbar docs for details.
Set an element to display: block
and center via margin
. Available as a mixin and class.
Clear the float
on any element with the .clearfix
class. Utilizes the micro clearfix as popularized by Nicolas Gallagher. Can also be used as a mixin.
Force an element to be shown or hidden (including for screen readers) with the use of .show
and .hidden
classes. These classes use !important
to avoid specificity conflicts, just like the quick floats. They are only available for block level toggling. They can also be used as mixins.
.hide
is available, but it does not always affect screen readers and is deprecated as of v3.0.1. Use .hidden
or .sr-only
instead.
Furthermore, .invisible
can be used to toggle only the visibility of an element, meaning its display
is not modified and the element can still affect the flow of the document.
Hide an element to all devices except screen readers with .sr-only
. Combine .sr-only
with .sr-only-focusable
to show the element again when it's focused (e.g. by a keyboard-only user). Necessary for following accessibility best practices. Can also be used as mixins.
Utilize the .text-hide
class or mixin to help replace an element's text content with a background image.
Images in Bootstrap 3 can be made responsive-friendly via the addition of the .img-responsive
class. This applies max-width: 100%;
and height: auto;
to the image so that it scales nicely to the parent element.
Add classes to an <img>
element to easily style images in any project.
Keep in mind that Internet Explorer 8 lacks support for rounded corners.
+Bootstrap's CSS is built on Less, a preprocessor with additional functionality like variables, mixins, and functions for compiling CSS. Those looking to use the source Less files instead of our compiled CSS files can make use of the numerous variables and mixins we use throughout the framework.
+ +Grid variables and mixins are covered within the Grid system section.
+ + +Bootstrap can be used in at least two ways: with the compiled CSS or with the source Less files. To compile the Less files, visit the README for how to setup your development environment to run the necessary commands.
+Third party compilation tools may work with Bootstrap, but they are not supported by our core team.
+ +Variables are used throughout the entire project as a way to centralize and share commonly used values like colors, spacing, or font stacks. For a complete breakdown, please see the Customizer.
+ +Easily make use of two color schemes: grayscale and semantic. Grayscale colors provide quick access to commonly used shades of black while semantic include various colors assigned to meaningful contextual values.
+Use any of these color variables as they are or reassign them to more meaningful variables for your project.
+{% highlight scss %} +// Use as-is +.masthead { + background-color: @brand-primary; +} + +// Reassigned variables in Less +@alert-message-background: @brand-info; +.alert { + background-color: @alert-message-background; +} +{% endhighlight %} + +A handful of variables for quickly customizing key elements of your site's skeleton.
+{% highlight scss %} +// Scaffolding +@body-bg: #fff; +@text-color: @black-50; +{% endhighlight %} + +Easily style your links with the right color with only one value.
+{% highlight scss %} +// Variables +@link-color: @brand-primary; +@link-color-hover: darken(@link-color, 15%); + +// Usage +a { + color: @link-color; + text-decoration: none; + + &:hover { + color: @link-color-hover; + text-decoration: underline; + } +} +{% endhighlight %} +Note that the @link-color-hover
uses a function, another awesome tool from Less, to automagically create the right hover color. You can use darken
, lighten
, saturate
, and desaturate
.
Easily set your type face, text size, leading, and more with a few quick variables. Bootstrap makes use of these as well to provide easy typographic mixins.
+{% highlight scss %} +@font-family-sans-serif: "Helvetica Neue", Helvetica, Arial, sans-serif; +@font-family-serif: Georgia, "Times New Roman", Times, serif; +@font-family-monospace: Menlo, Monaco, Consolas, "Courier New", monospace; +@font-family-base: @font-family-sans-serif; + +@font-size-base: 14px; +@font-size-large: ceil((@font-size-base * 1.25)); // ~18px +@font-size-small: ceil((@font-size-base * 0.85)); // ~12px + +@font-size-h1: floor((@font-size-base * 2.6)); // ~36px +@font-size-h2: floor((@font-size-base * 2.15)); // ~30px +@font-size-h3: ceil((@font-size-base * 1.7)); // ~24px +@font-size-h4: ceil((@font-size-base * 1.25)); // ~18px +@font-size-h5: @font-size-base; +@font-size-h6: ceil((@font-size-base * 0.85)); // ~12px + +@line-height-base: 1.428571429; // 20/14 +@line-height-computed: floor((@font-size-base * @line-height-base)); // ~20px + +@headings-font-family: inherit; +@headings-font-weight: 500; +@headings-line-height: 1.1; +@headings-color: inherit; +{% endhighlight %} + +Two quick variables for customizing the location and filename of your icons.
+{% highlight scss %} +@icon-font-path: "../fonts/"; +@icon-font-name: "glyphicons-halflings-regular"; +{% endhighlight %} + +Components throughout Bootstrap make use of some default variables for setting common values. Here are the most commonly used.
+{% highlight scss %} +@padding-base-vertical: 6px; +@padding-base-horizontal: 12px; + +@padding-large-vertical: 10px; +@padding-large-horizontal: 16px; + +@padding-small-vertical: 5px; +@padding-small-horizontal: 10px; + +@padding-xs-vertical: 1px; +@padding-xs-horizontal: 5px; + +@line-height-large: 1.33; +@line-height-small: 1.5; + +@border-radius-base: 4px; +@border-radius-large: 6px; +@border-radius-small: 3px; + +@component-active-color: #fff; +@component-active-bg: @brand-primary; + +@caret-width-base: 4px; +@caret-width-large: 5px; +{% endhighlight %} + + +Vendor mixins are mixins to help support multiple browsers by including all relevant vendor prefixes in your compiled CSS.
+ + +Reset your components' box model with a single mixin. For context, see this helpful article from Mozilla.
+The mixin is deprecated as of v3.2.0, with the introduction of autoprefixer. To preserve backwards-compatibility, Bootstrap will continue to use the mixin internally until Bootstrap v4.
+{% highlight scss %} +.box-sizing(@box-model) { + -webkit-box-sizing: @box-model; // Safari <= 5 + -moz-box-sizing: @box-model; // Firefox <= 19 + box-sizing: @box-model; +} +{% endhighlight %} + +Today all modern browsers support the non-prefixed border-radius
property. As such, there is no .border-radius()
mixin, but Bootstrap does include shortcuts for quickly rounding two corners on a particular side of an object.
If your target audience is using the latest and greatest browsers and devices, be sure to just use the box-shadow
property on its own. If you need support for older Android (pre-v4) and iOS devices (pre-iOS 5), use the deprecated mixin to pick up the required -webkit
prefix.
The mixin is deprecated as of v3.1.0, since Bootstrap doesn't officially support the outdated platforms that don't support the standard property. To preserve backwards-compatibility, Bootstrap will continue to use the mixin internally until Bootstrap v4.
+Be sure to use rgba()
colors in your box shadows so they blend as seamlessly as possible with backgrounds.
Multiple mixins for flexibility. Set all transition information with one, or specify a separate delay and duration as needed.
+The mixins are deprecated as of v3.2.0, with the introduction of autoprefixer. To preserve backwards-compatibility, Bootstrap will continue to use the mixins internally until Bootstrap v4.
+{% highlight scss %} +.transition(@transition) { + -webkit-transition: @transition; + transition: @transition; +} +.transition-property(@transition-property) { + -webkit-transition-property: @transition-property; + transition-property: @transition-property; +} +.transition-delay(@transition-delay) { + -webkit-transition-delay: @transition-delay; + transition-delay: @transition-delay; +} +.transition-duration(@transition-duration) { + -webkit-transition-duration: @transition-duration; + transition-duration: @transition-duration; +} +.transition-timing-function(@timing-function) { + -webkit-transition-timing-function: @timing-function; + transition-timing-function: @timing-function; +} +.transition-transform(@transition) { + -webkit-transition: -webkit-transform @transition; + -moz-transition: -moz-transform @transition; + -o-transition: -o-transform @transition; + transition: transform @transition; +} +{% endhighlight %} + +Rotate, scale, translate (move), or skew any object.
+The mixins are deprecated as of v3.2.0, with the introduction of autoprefixer. To preserve backwards-compatibility, Bootstrap will continue to use the mixins internally until Bootstrap v4.
+{% highlight scss %} +.rotate(@degrees) { + -webkit-transform: rotate(@degrees); + -ms-transform: rotate(@degrees); // IE9 only + transform: rotate(@degrees); +} +.scale(@ratio; @ratio-y...) { + -webkit-transform: scale(@ratio, @ratio-y); + -ms-transform: scale(@ratio, @ratio-y); // IE9 only + transform: scale(@ratio, @ratio-y); +} +.translate(@x; @y) { + -webkit-transform: translate(@x, @y); + -ms-transform: translate(@x, @y); // IE9 only + transform: translate(@x, @y); +} +.skew(@x; @y) { + -webkit-transform: skew(@x, @y); + -ms-transform: skewX(@x) skewY(@y); // See https://github.com/twbs/bootstrap/issues/4885; IE9+ + transform: skew(@x, @y); +} +.translate3d(@x; @y; @z) { + -webkit-transform: translate3d(@x, @y, @z); + transform: translate3d(@x, @y, @z); +} + +.rotateX(@degrees) { + -webkit-transform: rotateX(@degrees); + -ms-transform: rotateX(@degrees); // IE9 only + transform: rotateX(@degrees); +} +.rotateY(@degrees) { + -webkit-transform: rotateY(@degrees); + -ms-transform: rotateY(@degrees); // IE9 only + transform: rotateY(@degrees); +} +.perspective(@perspective) { + -webkit-perspective: @perspective; + -moz-perspective: @perspective; + perspective: @perspective; +} +.perspective-origin(@perspective) { + -webkit-perspective-origin: @perspective; + -moz-perspective-origin: @perspective; + perspective-origin: @perspective; +} +.transform-origin(@origin) { + -webkit-transform-origin: @origin; + -moz-transform-origin: @origin; + -ms-transform-origin: @origin; // IE9 only + transform-origin: @origin; +} +{% endhighlight %} + +A single mixin for using all of CSS3's animation properties in one declaration and other mixins for individual properties.
+The mixins are deprecated as of v3.2.0, with the introduction of autoprefixer. To preserve backwards-compatibility, Bootstrap will continue to use the mixins internally until Bootstrap v4.
+{% highlight scss %} +.animation(@animation) { + -webkit-animation: @animation; + animation: @animation; +} +.animation-name(@name) { + -webkit-animation-name: @name; + animation-name: @name; +} +.animation-duration(@duration) { + -webkit-animation-duration: @duration; + animation-duration: @duration; +} +.animation-timing-function(@timing-function) { + -webkit-animation-timing-function: @timing-function; + animation-timing-function: @timing-function; +} +.animation-delay(@delay) { + -webkit-animation-delay: @delay; + animation-delay: @delay; +} +.animation-iteration-count(@iteration-count) { + -webkit-animation-iteration-count: @iteration-count; + animation-iteration-count: @iteration-count; +} +.animation-direction(@direction) { + -webkit-animation-direction: @direction; + animation-direction: @direction; +} +{% endhighlight %} + +Set the opacity for all browsers and provide a filter
fallback for IE8.
Provide context for form controls within each field.
+{% highlight scss %} +.placeholder(@color: @input-color-placeholder) { + &::-moz-placeholder { color: @color; } // Firefox + &:-ms-input-placeholder { color: @color; } // Internet Explorer 10+ + &::-webkit-input-placeholder { color: @color; } // Safari and Chrome +} +{% endhighlight %} + +Generate columns via CSS within a single element.
+{% highlight scss %} +.content-columns(@width; @count; @gap) { + -webkit-column-width: @width; + -moz-column-width: @width; + column-width: @width; + -webkit-column-count: @count; + -moz-column-count: @count; + column-count: @count; + -webkit-column-gap: @gap; + -moz-column-gap: @gap; + column-gap: @gap; +} +{% endhighlight %} + +Easily turn any two colors into a background gradient. Get more advanced and set a direction, use three colors, or use a radial gradient. With a single mixin you get all the prefixed syntaxes you'll need.
+{% highlight scss %} +#gradient > .vertical(#333; #000); +#gradient > .horizontal(#333; #000); +#gradient > .radial(#333; #000); +{% endhighlight %} +You can also specify the angle of a standard two-color, linear gradient:
+{% highlight scss %} +#gradient > .directional(#333; #000; 45deg); +{% endhighlight %} +If you need a barber-stripe style gradient, that's easy, too. Just specify a single color and we'll overlay a translucent white stripe.
+{% highlight scss %} +#gradient > .striped(#333; 45deg); +{% endhighlight %} +Up the ante and use three colors instead. Set the first color, the second color, the second color's color stop (a decimal value like 0.25), and the third color with these mixins:
+{% highlight scss %} +#gradient > .vertical-three-colors(#777; #333; .25; #000); +#gradient > .horizontal-three-colors(#777; #333; .25; #000); +{% endhighlight %} +Heads up! Should you ever need to remove a gradient, be sure to remove any IE-specific filter
you may have added. You can do that by using the .reset-filter()
mixin alongside background-image: none;
.
Utility mixins are mixins that combine otherwise unrelated CSS properties to achieve a specific goal or task.
+ +Forget adding class="clearfix"
to any element and instead add the .clearfix()
mixin where appropriate. Uses the micro clearfix from Nicolas Gallager.
Quickly center any element within its parent. Requires width
or max-width
to be set.
Specify the dimensions of an object more easily.
+{% highlight scss %} +// Mixins +.size(@width; @height) { + width: @width; + height: @height; +} +.square(@size) { + .size(@size; @size); +} + +// Usage +.image { .size(400px; 300px); } +.avatar { .square(48px); } +{% endhighlight %} + +Easily configure the resize options for any textarea, or any other element. Defaults to normal browser behavior (both
).
Easily truncate text with an ellipsis with a single mixin. Requires element to be block
or inline-block
level.
Specify two image paths and the @1x image dimensions, and Bootstrap will provide an @2x media query. If you have many images to serve, consider writing your retina image CSS manually in a single media query.
+{% highlight scss %} +.img-retina(@file-1x; @file-2x; @width-1x; @height-1x) { + background-image: url("@{file-1x}"); + + @media + only screen and (-webkit-min-device-pixel-ratio: 2), + only screen and ( min--moz-device-pixel-ratio: 2), + only screen and ( -o-min-device-pixel-ratio: 2/1), + only screen and ( min-device-pixel-ratio: 2), + only screen and ( min-resolution: 192dpi), + only screen and ( min-resolution: 2dppx) { + background-image: url("@{file-2x}"); + background-size: @width-1x @height-1x; + } +} + +// Usage +.jumbotron { + .img-retina("/img/bg-1x.png", "/img/bg-2x.png", 100px, 100px); +} +{% endhighlight %} +Get the lowdown on the key pieces of Bootstrap's infrastructure, including our approach to better, faster, stronger web development.
+ +Bootstrap makes use of certain HTML elements and CSS properties that require the use of the HTML5 doctype. Include it at the beginning of all your projects.
+{% highlight html %} + + + ... + +{% endhighlight %} + +With Bootstrap 2, we added optional mobile friendly styles for key aspects of the framework. With Bootstrap 3, we've rewritten the project to be mobile friendly from the start. Instead of adding on optional mobile styles, they're baked right into the core. In fact, Bootstrap is mobile first. Mobile first styles can be found throughout the entire library instead of in separate files.
+To ensure proper rendering and touch zooming, add the viewport meta tag to your <head>
.
You can disable zooming capabilities on mobile devices by adding user-scalable=no
to the viewport meta tag. This disables zooming, meaning users are only able to scroll, and results in your site feeling a bit more like a native application. Overall, we don't recommend this on every site, so use caution!
Bootstrap sets basic global display, typography, and link styles. Specifically, we:
+background-color: #fff;
on the body
@font-family-base
, @font-size-base
, and @line-height-base
attributes as our typographic base@link-color
and apply link underlines only on :hover
These styles can be found within scaffolding.less
.
For improved cross-browser rendering, we use Normalize.css, a project by Nicolas Gallagher and Jonathan Neal.
+ +Bootstrap requires a containing element to wrap site contents and house our grid system. You may choose one of two containers to use in your projects. Note that, due to padding
and more, neither container is nestable.
Use .container
for a responsive fixed width container.
Use .container-fluid
for a full width container, spanning the entire width of your viewport.
For faster mobile-friendly development, use these utility classes for showing and hiding content by device via media query. Also included are utility classes for toggling content when printed.
+Try to use these on a limited basis and avoid creating entirely different versions of the same site. Instead, use them to complement each device's presentation.
+ + +Use a single or combination of the available classes for toggling content across viewport breakpoints.
++ | + Extra small devices + Phones (<768px) + | ++ Small devices + Tablets (≥768px) + | ++ Medium devices + Desktops (≥992px) + | ++ Large devices + Desktops (≥1200px) + | +
---|---|---|---|---|
.visible-xs-* |
+ Visible | +Hidden | +Hidden | +Hidden | +
.visible-sm-* |
+ Hidden | +Visible | +Hidden | +Hidden | +
.visible-md-* |
+ Hidden | +Hidden | +Visible | +Hidden | +
.visible-lg-* |
+ Hidden | +Hidden | +Hidden | +Visible | +
.hidden-xs |
+ Hidden | +Visible | +Visible | +Visible | +
.hidden-sm |
+ Visible | +Hidden | +Visible | +Visible | +
.hidden-md |
+ Visible | +Visible | +Hidden | +Visible | +
.hidden-lg |
+ Visible | +Visible | +Visible | +Hidden | +
As of v3.2, the .visible-*-*
classes for each breakpoint come in three variations, one for each CSS display
property value listed below.
Group of classes | +CSS display |
+
---|---|
.visible-*-block |
+ display: block; |
+
.visible-*-inline |
+ display: inline; |
+
.visible-*-inline-block |
+ display: inline-block; |
+
So, for extra small (xs
) screens for example, the available .visible-*-*
classes are: .visible-xs-block
, .visible-xs-inline
, and .visible-xs-inline-block
.
The classes .visible-xs
, .visible-sm
, .visible-md
, and .visible-lg
also exist, but are deprecated as of v3.2. They are approximately equivalent to .visible-*-block
, except with additional special cases for toggling <table>
-related elements.
Similar to the regular responsive classes, use these for toggling content for print.
+Classes | +Browser | +|
---|---|---|
+ .visible-print-block + .visible-print-inline + .visible-print-inline-block
+ |
+ Hidden | +Visible | +
.hidden-print |
+ Visible | +Hidden | +
The class .visible-print
also exists but is deprecated as of v3.1.0. It is approximately equivalent to .visible-print-block
, except with additional special cases for <table>
-related elements.
Resize your browser or load on different devices to test the responsive utility classes.
+ +Green checkmarks indicate the element is visible in your current viewport.
+Here, green checkmarks also indicate the element is hidden in your current viewport.
+ + +As of Bootstrap 3.2, a right-to-left version of Bootstrap ships as part of the repository. It's powered by Twitter's CSS Flip project and is generated via our Gruntfile.
+ +Bootstrap is by default a left-to-right project. For right-to-left projects, you'll need to set your language and replace the default Bootstrap CSS with an RTL version. First, set your language and text direction:
+{% highlight html %} + + +{% endhighlight %} +Then, include the right-to-left CSS file in place of the default Bootstrap CSS:
+{% highlight html %} + + +{% endhighlight %} +Alternatively, you may use the minified RTL file, bootstrap-rtl.min.css
.
CSS Flip is a project for converting left-to-right CSS files into right-to-left CSS files. We use it in our Gruntfile to automate the generation of Bootstrap's RTL CSS files.
+While Bootstrap is built on Less, it also has an official Sass port. We maintain it in a separate GitHub repository and handle updates with a conversion script.
+ +Since the Sass port has a separate repo and serves a slightly different audience, the contents of the project differ greatly from the main Bootstrap project. This ensures the Sass port is as compatible with as many Sass-based systems as possible.
+ +Path | +Description | +
---|---|
lib/ |
+ Ruby gem code (Sass configuration, Rails and Compass integrations) | +
tasks/ |
+ Converter scripts (turning upstream Less to Sass) | +
test/ |
+ Compilation tests | +
templates/ |
+ Compass package manifest | +
vendor/assets/ |
+ Sass, JavaScript, and font files | +
Rakefile |
+ Internal tasks, such as rake and convert | +
Visit the Sass port's GitHub repository to see these files in action.
+ + +For information on how to install and use Bootstrap for Sass, consult the GitHub repository readme. It's the most up to date source and includes information for use with Rails, Compass, and standard Sass projects.
+ +For basic styling—light padding and only horizontal dividers—add the base class .table
to any <table>
. It may seem super redundant, but given the widespread use of tables for other plugins like calendars and date pickers, we've opted to isolate our custom table styles.
# | +First Name | +Last Name | +Username | +
---|---|---|---|
1 | +Mark | +Otto | +@mdo | +
2 | +Jacob | +Thornton | +@fat | +
3 | +Larry | +the Bird | +
Use .table-striped
to add zebra-striping to any table row within the <tbody>
.
Striped tables are styled via the :nth-child
CSS selector, which is not available in Internet Explorer 8.
# | +First Name | +Last Name | +Username | +
---|---|---|---|
1 | +Mark | +Otto | +@mdo | +
2 | +Jacob | +Thornton | +@fat | +
3 | +Larry | +the Bird | +
Add .table-bordered
for borders on all sides of the table and cells.
# | +First Name | +Last Name | +Username | +
---|---|---|---|
1 | +Mark | +Otto | +@mdo | +
Mark | +Otto | +@TwBootstrap | +|
2 | +Jacob | +Thornton | +@fat | +
3 | +Larry the Bird | +
Add .table-hover
to enable a hover state on table rows within a <tbody>
.
# | +First Name | +Last Name | +Username | +
---|---|---|---|
1 | +Mark | +Otto | +@mdo | +
2 | +Jacob | +Thornton | +@fat | +
3 | +Larry the Bird | +
Add .table-condensed
to make tables more compact by cutting cell padding in half.
# | +First Name | +Last Name | +Username | +
---|---|---|---|
1 | +Mark | +Otto | +@mdo | +
2 | +Jacob | +Thornton | +@fat | +
3 | +Larry the Bird | +
Use contextual classes to color table rows or individual cells.
+Class | +Description | +
---|---|
+ .active
+ |
+ Applies the hover color to a particular row or cell | +
+ .success
+ |
+ Indicates a successful or positive action | +
+ .info
+ |
+ Indicates a neutral informative change or action | +
+ .warning
+ |
+ Indicates a warning that might need attention | +
+ .danger
+ |
+ Indicates a dangerous or potentially negative action | +
# | +Column heading | +Column heading | +Column heading | +
---|---|---|---|
1 | +Column content | +Column content | +Column content | +
2 | +Column content | +Column content | +Column content | +
3 | +Column content | +Column content | +Column content | +
4 | +Column content | +Column content | +Column content | +
5 | +Column content | +Column content | +Column content | +
6 | +Column content | +Column content | +Column content | +
7 | +Column content | +Column content | +Column content | +
8 | +Column content | +Column content | +Column content | +
9 | +Column content | +Column content | +Column content | +
Create responsive tables by wrapping any .table
in .table-responsive
to make them scroll horizontally up to small devices (under 768px). When viewing on anything larger than 768px wide, you will not see any difference in these tables.
# | +Table heading | +Table heading | +Table heading | +Table heading | +Table heading | +Table heading | +
---|---|---|---|---|---|---|
1 | +Table cell | +Table cell | +Table cell | +Table cell | +Table cell | +Table cell | +
2 | +Table cell | +Table cell | +Table cell | +Table cell | +Table cell | +Table cell | +
3 | +Table cell | +Table cell | +Table cell | +Table cell | +Table cell | +Table cell | +
# | +Table heading | +Table heading | +Table heading | +Table heading | +Table heading | +Table heading | +
---|---|---|---|---|---|---|
1 | +Table cell | +Table cell | +Table cell | +Table cell | +Table cell | +Table cell | +
2 | +Table cell | +Table cell | +Table cell | +Table cell | +Table cell | +Table cell | +
3 | +Table cell | +Table cell | +Table cell | +Table cell | +Table cell | +Table cell | +
All HTML headings, <h1>
through <h6>
, are available. .h1
through .h6
classes are also available, for when you want to match the font styling of a heading but still want your text to be displayed inline.
h1. Bootstrap heading |
+ Semibold 36px | +
h2. Bootstrap heading |
+ Semibold 30px | +
h3. Bootstrap heading |
+ Semibold 24px | +
h4. Bootstrap heading |
+ Semibold 18px | +
h5. Bootstrap heading |
+ Semibold 14px | +
h6. Bootstrap heading |
+ Semibold 12px | +
Create lighter, secondary text in any heading with a generic <small>
tag or the .small
class.
h1. Bootstrap heading Secondary text |
+
h2. Bootstrap heading Secondary text |
+
h3. Bootstrap heading Secondary text |
+
h4. Bootstrap heading Secondary text |
+
h5. Bootstrap heading Secondary text |
+
h6. Bootstrap heading Secondary text |
+
Bootstrap's global default font-size
is 14px, with a line-height
of 1.428. This is applied to the <body>
and all paragraphs. In addition, <p>
(paragraphs) receive a bottom margin of half their computed line-height (10px by default).
Nullam quis risus eget urna mollis ornare vel eu leo. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nullam id dolor id nibh ultricies vehicula.
+Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec ullamcorper nulla non metus auctor fringilla. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit. Donec ullamcorper nulla non metus auctor fringilla.
+Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit.
+...
+{% endhighlight %} + + +Make a paragraph stand out by adding .lead
.
Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor. Duis mollis, est non commodo luctus.
+...
+{% endhighlight %} + + +The typographic scale is based on two Less variables in variables.less: @font-size-base
and @line-height-base
. The first is the base font-size used throughout and the second is the base line-height. We use those variables and some simple math to create the margins, paddings, and line-heights of all our type and more. Customize them and Bootstrap adapts.
For indicating blocks of text that have been deleted use the <mark>
tag.
You can use the mark tag to highlight text.
+For indicating blocks of text that have been deleted use the <del>
tag.
This line of text is meant to be treated as deleted text.
For indicating blocks of text that are no longer relevant use the <s>
tag.
This line of text is meant to be treated as no longer accurate.
For indicating additions to the document use the <ins>
tag.
This line of text is meant to be treated as an addition to the document.
+To underline text use the <u>
tag.
This line of text is will render as underlined
+Make use of HTML's default emphasis tags with lightweight styles.
+ +For de-emphasizing inline or blocks of text, use the <small>
tag to set text at 85% the size of the parent. Heading elements receive their own font-size
for nested <small>
elements.
You may alternatively use an inline element with .small
in place of any <small>
.
This line of text is meant to be treated as fine print.
+For emphasizing a snippet of text with a heavier font-weight.
+The following snippet of text is rendered as bold text.
+For emphasizing a snippet of text with italics.
+The following snippet of text is rendered as italicized text.
+Feel free to use <b>
and <i>
in HTML5. <b>
is meant to highlight words or phrases without conveying additional importance while <i>
is mostly for voice, technical terms, etc.
Easily realign text to components with text alignment classes.
+Left aligned text.
+Center aligned text.
+Right aligned text.
+Justified text.
+Left aligned text.
+Center aligned text.
+Right aligned text.
+Justified text.
+{% endhighlight %} + + + +Stylized implementation of HTML's <abbr>
element for abbreviations and acronyms to show the expanded version on hover. Abbreviations with a title
attribute have a light dotted bottom border and a help cursor on hover, providing additional context on hover.
For expanded text on long hover of an abbreviation, include the title
attribute with the <abbr>
element.
An abbreviation of the word attribute is attr.
+Add .initialism
to an abbreviation for a slightly smaller font-size.
HTML is the best thing since sliced bread.
+Present contact information for the nearest ancestor or the entire body of work. Preserve formatting by ending all lines with <br>
.
For quoting blocks of content from another source within your document.
+ +Wrap <blockquote>
around any HTML as the quote. For straight quotes, we recommend a <p>
.
++Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat a ante.
+
++{% endhighlight %} + +Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat a ante.
+
Style and content changes for simple variations on a standard <blockquote>
.
Add a <footer>
for identifying the source. Wrap the name of the source work in <cite>
.
++Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat a ante.
+ +
++{% endhighlight %} + +Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat a ante.
+ +
Add .blockquote-reverse
for a blockquote with right-aligned content.
+ ... ++{% endhighlight %} + + + +
A list of items in which the order does not explicitly matter.
+A list of items in which the order does explicitly matter.
+Remove the default list-style
and left margin on list items (immediate children only). This only applies to immediate children list items, meaning you will need to add the class for any nested lists as well.
Place all list items on a single line with display: inline-block;
and some light padding.
A list of terms with their associated descriptions.
+Make terms and descriptions in <dl>
line up side-by-side. Starts off stacked like default <dl>
s, but when the navbar expands, so do these.
Horizontal description lists will truncate terms that are too long to fit in the left column with text-overflow
. In narrower viewports, they will change to the default stacked layout.
Bootstrap follows common web standards and—with minimal extra effort—can be used to create sites that are accessible to those using AT.
+ +If your navigation contains many links and comes before the main content in the DOM, add a Skip to main content
link immediately after your opening <body>
tag. (read why)
When nesting headings (<h1>
- <h6>
), your primary document header should be an <h1>
. Subsequent headings should make logical use of <h2>
- <h6>
such that screen readers can construct a table of contents for your pages.
Learn more at HTML CodeSniffer and Penn State's AccessAbility.
+ +Bootstrap is built to work best in the latest desktop and mobile browsers, meaning older browsers might display differently styled, though fully functional, renderings of certain components.
+ +Specifically, we support the latest versions of the following browsers and platforms. On Windows, we support Internet Explorer 8-11. More specific support information is provided below.
++ | Chrome | +Firefox | +Internet Explorer | +Opera | +Safari | +
---|---|---|---|---|---|
Android | +Supported | +Not Supported | +N/A | +Not Supported | +N/A | +
iOS | +Supported | +N/A | +Not Supported | +Supported | +|
Mac OS X | +Supported | +Supported | +Supported | +Supported | +|
Windows | +Supported | +Supported | +Supported | +Supported | +Not Supported | +
Unofficially, Bootstrap should look and behave well enough in Chromium and Chrome for Linux, Firefox for Linux, and Internet Explorer 7, though they are not officially supported.
+For a list of some of the browser bugs that Bootstrap has to grapple with, see our Wall of browser bugs.
+ +Internet Explorer 8 and 9 are also supported, however, please be aware that some CSS3 properties and HTML5 elements are not fully supported by these browsers. In addition, Internet Explorer 8 requires the use of Respond.js to enable media query support.
+Feature | +Internet Explorer 8 | +Internet Explorer 9 | +
---|---|---|
border-radius |
+ Not supported | +Supported | +
box-shadow |
+ Not supported | +Supported | +
transform |
+ Not supported | + Supported, with -ms prefix |
+
transition |
+ Not supported | +|
placeholder |
+ Not supported | +
Visit Can I use... for details on browser support of CSS3 and HTML5 features.
+ +Beware of the following caveats when using Respond.js in your development and production environments for Internet Explorer 8.
+Using Respond.js with CSS hosted on a different (sub)domain (for example, on a CDN) requires some additional setup. See the Respond.js docs for details.
+file://
Due to browser security rules, Respond.js doesn't work with pages viewed via the file://
protocol (like when opening a local HTML file). To test responsive features in IE8, view your pages over HTTP(S). See the Respond.js docs for details.
@import
Respond.js doesn't work with CSS that's referenced via @import
. In particular, some Drupal configurations are known to use @import
. See the Respond.js docs for details.
IE8 does not fully support box-sizing: border-box;
when combined with min-width
, max-width
, min-height
, or max-height
. For that reason, as of v3.0.1, we no longer use max-width
on .container
s.
Bootstrap is not supported in the old Internet Explorer compatibility modes. To be sure you're using the latest rendering mode for IE, consider including the appropriate <meta>
tag in your pages:
Confirm the document mode by opening the debugging tools: press F12 and check the "Document Mode".
+This tag is included in all Bootstrap's documentation and examples to ensure the best rendering possible in each supported version of Internet Explorer.
+See this StackOverflow question for more information.
+ +Internet Explorer 10 doesn't differentiate device width from viewport width, and thus doesn't properly apply the media queries in Bootstrap's CSS. Normally you'd just add a quick snippet of CSS to fix this:
+{% highlight scss %} +@-ms-viewport { width: device-width; } +{% endhighlight %} +However, this doesn't work for devices running Windows Phone 8 versions older than Update 3 (a.k.a. GDR3), as it causes such devices to show a mostly desktop view instead of narrow "phone" view. To address this, you'll need to include the following CSS and JavaScript to work around the bug.
+{% highlight scss %} +@-webkit-viewport { width: device-width; } +@-moz-viewport { width: device-width; } +@-ms-viewport { width: device-width; } +@-o-viewport { width: device-width; } +@viewport { width: device-width; } +{% endhighlight %} + +{% highlight js %} +if (navigator.userAgent.match(/IEMobile\/10\.0/)) { + var msViewportStyle = document.createElement('style') + msViewportStyle.appendChild( + document.createTextNode( + '@-ms-viewport{width:auto!important}' + ) + ) + document.querySelector('head').appendChild(msViewportStyle) +} +{% endhighlight %} +For more information and usage guidelines, read Windows Phone 8 and Device-Width.
+As a heads up, we include this in the Bootstrap docs as an example.
+ +As of Safari v7.0.1 for OS X and Safari for iOS v7.0.1, Safari's rendering engine has some trouble with the number of decimal places used in our .col-*-1
grid classes. So if you have 12 individual grid columns, you'll notice that they come up short compared to other rows of columns. We can't do much here (see #9282) but you do have some options:
.pull-right
to your last grid column to get the hard-right alignmentWe'll keep an eye on this though and update our code if we have an easy solution.
+ +Support for overflow: hidden
on the <body>
element is quite limited in iOS and Android. To that end, when you scroll past the top or bottom of a modal in either of those devices' browsers, the <body>
content will begin to scroll.
Also, note that if you're using inputs in your modal or navbar, iOS has a rendering bug that doesn't update the position of fixed elements when the virtual keyboard is triggered. A few workarounds for this include transforming your elements to position: absolute
or invoking a timer on focus to try to correct the positioning manually. This is not handled by Bootstrap, so it is up to you to decide which solution is best for your application.
The .dropdown-backdrop
element isn't used on iOS in the nav because of the complexity of z-indexing. Thus, to close dropdowns in navbars, you must directly click the dropdown element (or any other element which will fire a click event in iOS).
Page zooming inevitably presents rendering artifacts in some components, both in Bootstrap and the rest of the web. Depending on the issue, we may be able to fix it (search first and then open an issue if need be). However, we tend to ignore these as they often have no direct solution other than hacky workarounds.
+ +Even in some modern browsers, printing can be quirky. In particular, as of Chrome v32 and regardless of margin settings, Chrome uses a viewport width significantly narrower than the physical paper size when resolving media queries while printing a webpage. This can result in Bootstrap's extra-small grid being unexpectedly activated when printing. See #12078 for some details. Suggested workarounds:
+@screen-*
Less variables so that your printer paper is considered larger than extra-small.Out of the box, Android 4.1 (and even some newer releases apparently) ship with the Browser app as the default web browser of choice (as opposed to Chrome). Unfortunately, the Browser app has lots of bugs and inconsistencies with CSS in general.
+On <select>
elements, the Android stock browser will not display the side controls if there is a border-radius
and/or border
applied. Use the snippet of code below to remove the offending CSS and render the <select>
as an unstyled element on the Android stock browser. The user agent sniffing avoids interference with Chrome, Safari, and Mozilla browsers.
Want to see an example? Check out this JS Bin demo.
+Stay up to date on the development of Bootstrap and reach out to the community with these helpful resources.
+irc.freenode.net
server, in the ##twitter-bootstrap channel.twitter-bootstrap-3
.You can also follow @twbootstrap on Twitter for the latest gossip and awesome music videos.
+Bootstrap automatically adapts your pages for various screen sizes. + Here's how to disable this feature so your page works like in this non-responsive example.
+ +<meta>
mentioned in the CSS docswidth
on the .container
for each grid tier with a single width, for example width: 970px !important;
Be sure that this comes after the default Bootstrap CSS. You can optionally avoid the !important
with media queries or some selector-fu..col-xs-*
classes in addition to, or in place of, the medium/large ones. Don't worry, the extra-small device grid scales to all resolutions.You'll still need Respond.js for IE8 (since our media queries are still there and need to be processed). + This disables the "mobile site" aspects of Bootstrap.
+ +We've applied these steps to an example. Read its source code to see the specific changes implemented.
+ +Bootstrap (currently v{{ site.current_version }}) has a few easy ways to quickly get started, each one appealing to a different skill level and use case. Read through to see what suits your particular needs.
+ +Compiled and minified CSS, JavaScript, and fonts. No docs or original source files are included.
+ +Source Less, JavaScript, and font files, along with our docs. Requires a Less compiler and some setup.
++ Download source +
+Bootstrap ported from Less to Sass for easy inclusion in Rails, Compass, or Sass-only projects.
++ Download Sass +
+The folks over at MaxCDN graciously provide CDN support for Bootstrap's CSS and JavaScript. Just use these Bootstrap CDN links.
+{% highlight html %} + + + + + + + + +{% endhighlight %} + +Install and manage Bootstrap's Less, CSS, JavaScript, and fonts using Bower.
+ {% highlight bash %}$ bower install bootstrap{% endhighlight %} +Build on the basic template above with Bootstrap's many components. See also Customizing Bootstrap for tips on maintaining your own Bootstrap variants.
+ +Nothing but the basics: compiled CSS and JavaScript along with a container.
+Build a more custom page by narrowing the default container and jumbotron.
+Super basic template that includes the navbar along with some additional content.
+Super basic template with a static top navbar along with some additional content.
+Super basic template with a fixed top navbar along with some additional content.
+Create a custom navbar with justified links. Heads up! Not too WebKit friendly.
+Attach a footer to the bottom of the viewport when the content is shorter than it.
+Attach a footer to the bottom of the viewport with a fixed navbar at the top.
+Bootstrap is released under the MIT license and is copyright {{ site.time | date: "%Y" }} Twitter. Boiled down to smaller chunks, it can be described with the following conditions.
+ +The full Bootstrap license is located in the project repository for more information.
+Start with this basic HTML template, or modify these examples. We hope you'll customize our templates and examples, adapting them to suit your needs.
+ +Copy the HTML below to begin working with a minimal Bootstrap document.
+{% highlight html %} + + + + + + +While we don't officially support any third party plugins or add-ons, we do offer some useful advice to help avoid potential issues in your projects.
+ +Some third party software, including Google Maps and Google Custom Search Engine, conflict with Bootstrap due to * { box-sizing: border-box; }
, a rule which makes it so padding
does not affect the final computed width of an element. Learn more about box model and sizing at CSS Tricks.
Depending on the context, you may override as-needed (Option 1) or reset the box-sizing for entire regions (Option 2).
+{% highlight scss %} +/* Box-sizing resets + * + * Reset individual elements or override regions to avoid conflicts due to + * global box model settings of Bootstrap. Two options, individual overrides and + * region resets, are available as plain CSS and uncompiled Less formats. + */ + +/* Option 1A: Override a single element's box model via CSS */ +.element { + -webkit-box-sizing: content-box; + -moz-box-sizing: content-box; + box-sizing: content-box; +} + +/* Option 1B: Override a single element's box model by using a Bootstrap Less mixin */ +.element { + .box-sizing(content-box); +} + +/* Option 2A: Reset an entire region via CSS */ +.reset-box-sizing, +.reset-box-sizing *, +.reset-box-sizing *:before, +.reset-box-sizing *:after { + -webkit-box-sizing: content-box; + -moz-box-sizing: content-box; + box-sizing: content-box; +} + +/* Option 2B: Reset an entire region with a custom Less mixin */ +.reset-box-sizing { + &, + *, + *:before, + *:after { + .box-sizing(content-box); + } +} +.element { + .reset-box-sizing(); +} +{% endhighlight %} +Community members have translated Bootstrap's documentation into various languages. None are officially supported and they may not always be up to date.
+We don't help organize or host translations, we just link to them.
+Finished a new or better translation? Open a pull request to add it to our list.
+Bootstrap is downloadable in two forms, within which you'll find the following directories and files, logically grouping common resources and providing both compiled and minified variations.
+ +Please note that all JavaScript plugins require jQuery to be included, as shown in the starter template. Consult our bower.json
to see which versions of jQuery are supported.
Once downloaded, unzip the compressed folder to see the structure of (the compiled) Bootstrap. You'll see something like this:
+ +{% highlight bash %} +bootstrap/ +├── css/ +│ ├── bootstrap.css +│ ├── bootstrap.min.css +│ ├── bootstrap-theme.css +│ └── bootstrap-theme.min.css +├── js/ +│ ├── bootstrap.js +│ └── bootstrap.min.js +└── fonts/ + ├── glyphicons-halflings-regular.eot + ├── glyphicons-halflings-regular.svg + ├── glyphicons-halflings-regular.ttf + └── glyphicons-halflings-regular.woff +{% endhighlight %} + +This is the most basic form of Bootstrap: precompiled files for quick drop-in usage in nearly any web project. We provide compiled CSS and JS (bootstrap.*
), as well as compiled and minified CSS and JS (bootstrap.min.*
). Fonts from Glyphicons are included, as is the optional Bootstrap theme.
The Bootstrap source code download includes the precompiled CSS, JavaScript, and font assets, along with source Less, JavaScript, and documentation. More specifically, it includes the following and more:
+{% highlight bash %} +bootstrap/ +├── less/ +├── js/ +├── fonts/ +├── dist/ +│ ├── css/ +│ ├── js/ +│ └── fonts/ +└── docs/ + └── examples/ +{% endhighlight %} +The less/
, js/
, and fonts/
are the source code for our CSS, JS, and icon fonts (respectively). The dist/
folder includes everything listed in the precompiled download section above. The docs/
folder includes the source code for our documentation, and examples/
of Bootstrap usage. Beyond that, any other included file provides support for packages, license information, and development.
The subnavigation on the right is a live demo of the affix plugin.
+ +Use the affix plugin via data attributes or manually with your own JavaScript. In both situations, you must provide CSS for the positioning of your content.
+ +The affix plugin toggles between three classes, each representing a particular state: .affix
, .affix-top
, and .affix-bottom
. You must provide the styles for these classes yourself (independent of this plugin) to handle the actual positions.
Here's how the affix plugin works:
+.affix-top
to indicate the element is in its top-most position. At this point no CSS positioning is required..affix
replaces .affix-top
and sets position: fixed;
(provided by Bootstrap's code CSS)..affix
with .affix-bottom
. Since offsets are optional, setting one requires you to set the appropriate CSS. In this case, add position: absolute;
when necessary. The plugin uses the data attribute or JavaScript option to determine where to position the element from there.Follow the above steps to set your CSS for either of the usage options below.
+ +To easily add affix behavior to any element, just add data-spy="affix"
to the element you want to spy on. Use offsets to define when to toggle the pinning of an element.
Call the affix plugin via JavaScript:
+{% highlight js %} + $('#my-affix').affix({ + offset: { + top: 100 + , bottom: function () { + return (this.bottom = $('.footer').outerHeight(true)) + } + } + }) +{% endhighlight %} + + +Options can be passed via data attributes or JavaScript. For data attributes, append the option name to data-
, as in data-offset-top="200"
.
Name | +type | +default | +description | +
---|---|---|---|
offset | +number | function | object | +10 | +Pixels to offset from screen when calculating position of scroll. If a single number is provided, the offset will be applied in both top and bottom directions. To provide a unique, bottom and top offset just provide an object offset: { top: 10 } or offset: { top: 10, bottom: 5 } . Use a function when you need to dynamically calculate an offset. |
+
Bootstrap's affix class exposes a few events for hooking into affix functionality.
+Event Type | +Description | +
---|---|
affix.bs.affix | +This event fires immediately before the element has been affixed. | +
affixed.bs.affix | +This event is fired after the element has been affixed. | +
affix-top.bs.affix | +This event fires immediately before the element has been affixed-top. | +
affixed-top.bs.affix | +This event is fired after the element has been affixed-top. | +
affix-bottom.bs.affix | +This event fires immediately before the element has been affixed-bottom. | +
affixed-bottom.bs.affix | +This event is fired after the element has been affixed-bottom. | +
Do more with buttons. Control button states or create groups of buttons for more components like toolbars.
+ +Add data-loading-text="Loading..."
to use a loading state on a button.
Add data-toggle="button"
to activate toggling on a single button.
Add data-toggle="buttons"
to a group of checkboxes for checkbox style toggling on btn-group.
Add data-toggle="buttons"
to a group of radio inputs for radio style toggling on btn-group.
Enable buttons via JavaScript:
+{% highlight js %} +$('.btn').button() +{% endhighlight %} + +Data attributes are integral to the button plugin. Check out the example code below for the various markup types.
+ +None
+ +Toggles push state. Gives the button the appearance that it has been activated.
+You can enable auto toggling of a button by using the data-toggle
attribute.
Sets button state to loading - disables button and swaps text to loading text. Loading text should be defined on the button element using the data attribute data-loading-text
.
+
Firefox persists the disabled state across page loads. A workaround for this is to use autocomplete="off"
.
Resets button state - swaps text to original text.
+ +Resets button state - swaps text to any data defined text state.
+{% highlight html %} + + +{% endhighlight %} +The slideshow below shows a generic plugin and component for cycling through elements like a carousel.
+Bootstrap exclusively uses CSS3 for its animations, but Internet Explorer 8 & 9 don't support the necessary CSS properties. Thus, there are no slide transition animations when using these browsers. We have intentionally decided not to include jQuery-based fallbacks for the transitions.
+Add captions to your slides easily with the .carousel-caption
element within any .item
. Place just about any optional HTML within there and it will be automatically aligned and formatted.
...
+The carousel component is generally not compliant with accessibility standards. If you need to be compliant, please consider other options for presenting your content.
+Carousels require the use of an id
on the outermost container, .carousel
, for carousel controls to function properly. When adding multiple carousels, or when changing a carousel's id
, be sure to update the relevant controls.
Use data attributes to easily control the position of the carousel. data-slide
accepts the keywords prev
or next
, which alters the slide position relative to its current position. Alternatively, use data-slide-to
to pass a raw slide index to the carousel data-slide-to="2"
, which shifts the slide position to a particular index beginning with 0
.
The data-ride="carousel"
attribute is used to mark a carousel as animating starting at page load.
Call carousel manually with:
+{% highlight js %} +$('.carousel').carousel() +{% endhighlight %} + +Options can be passed via data attributes or JavaScript. For data attributes, append the option name to data-
, as in data-interval=""
.
Name | +type | +default | +description | +
---|---|---|---|
interval | +number | +5000 | +The amount of time to delay between automatically cycling an item. If false, carousel will not automatically cycle. | +
pause | +string | +"hover" | +Pauses the cycling of the carousel on mouseenter and resumes the cycling of the carousel on mouseleave. | +
wrap | +boolean | +true | +Whether the carousel should cycle continuously or have hard stops. | +
Initializes the carousel with an optional options object
and starts cycling through items.
Cycles through the carousel items from left to right.
+ +Stops the carousel from cycling through items.
+ + +Cycles the carousel to a particular frame (0 based, similar to an array).
+ +Cycles to the previous item.
+ +Cycles to the next item.
+ +Bootstrap's carousel class exposes two events for hooking into carousel functionality.
+Event Type | +Description | +
---|---|
slide.bs.carousel | +This event fires immediately when the slide instance method is invoked. |
+
slid.bs.carousel | +This event is fired when the carousel has completed its slide transition. | +
Get base styles and flexible support for collapsible components like accordions and navigation.
+ +Collapse requires the transitions plugin to be included in your version of Bootstrap.
+Using the collapse plugin, we built a simple accordion by extending the panel component.
+ +You can also use the plugin without the accordion markup. Make a button toggle the expanding and collapsing of another element.
+{% highlight html %} + + +The collapse plugin utilizes a few classes to handle the heavy lifting:
+.collapse
hides the content.collapse.in
shows the content.collapsing
is added when the transition starts, and removed when it finishesThese classes can be found in component-animations.less
.
Just add data-toggle="collapse"
and a data-target
to element to automatically assign control of a collapsible element. The data-target
attribute accepts a CSS selector to apply the collapse to. Be sure to add the class collapse
to the collapsible element. If you'd like it to default open, add the additional class in
.
To add accordion-like group management to a collapsible control, add the data attribute data-parent="#selector"
. Refer to the demo to see this in action.
Enable manually with:
+{% highlight js %} +$('.collapse').collapse() +{% endhighlight %} + +Options can be passed via data attributes or JavaScript. For data attributes, append the option name to data-
, as in data-parent=""
.
Name | +type | +default | +description | +
---|---|---|---|
parent | +selector | +false | +If selector then all collapsible elements under the specified parent will be closed when this collapsible item is shown. (similar to traditional accordion behavior - this dependent on the panel class) |
+
toggle | +boolean | +true | +Toggles the collapsible element on invocation | +
Activates your content as a collapsible element. Accepts an optional options object
.
+{% highlight js %}
+$('#myCollapsible').collapse({
+ toggle: false
+})
+{% endhighlight %}
+
+
Toggles a collapsible element to shown or hidden.
+ +Shows a collapsible element.
+ +Hides a collapsible element.
+ +Bootstrap's collapse class exposes a few events for hooking into collapse functionality.
+Event Type | +Description | +
---|---|
show.bs.collapse | +This event fires immediately when the show instance method is called. |
+
shown.bs.collapse | +This event is fired when a collapse element has been made visible to the user (will wait for CSS transitions to complete). | +
hide.bs.collapse | +
+ This event is fired immediately when the hide method has been called.
+ |
+
hidden.bs.collapse | +This event is fired when a collapse element has been hidden from the user (will wait for CSS transitions to complete). | +
Add dropdown menus to nearly anything with this simple plugin, including the navbar, tabs, and pills.
+ +Via data attributes or JavaScript, the dropdown plugin toggles hidden content (dropdown menus) by toggling the .open
class on the parent list item. When opened, the plugin also adds .dropdown-backdrop
as a click area for closing dropdown menus when clicking outside the menu. Note: The data-toggle=dropdown
attribute is relied on for closing dropdown menus at an application level, so it's a good idea to always use it.
Add data-toggle="dropdown"
to a link or button to toggle a dropdown.
To keep URLs intact, use the data-target
attribute instead of href="#"
.
Call the dropdowns via JavaScript:
+{% highlight js %} +$('.dropdown-toggle').dropdown() +{% endhighlight %} +data-toggle="dropdown"
still requiredRegardless of whether you call your dropdown via JavaScript or instead use the data-api, data-toggle="dropdown"
is always required to be present on the dropdown's trigger element.
None
+ +Toggles the dropdown menu of a given navbar or tabbed navigation.
+ +All dropdown events are fired at the .dropdown-menu
's parent element.
Event Type | +Description | +
---|---|
show.bs.dropdown | +This event fires immediately when the show instance method is called. The toggling anchor element is available as the relatedTarget property of the event. |
+
shown.bs.dropdown | +This event is fired when the dropdown has been made visible to the user (will wait for CSS transitions, to complete). The toggling anchor element is available as the relatedTarget property of the event. |
+
hide.bs.dropdown | +This event is fired immediately when the hide instance method has been called. The toggling anchor element is available as the relatedTarget property of the event. |
+
hidden.bs.dropdown | +This event is fired when the dropdown has finished being hidden from the user (will wait for CSS transitions, to complete). The toggling anchor element is available as the relatedTarget property of the event. |
+
Modals are streamlined, but flexible, dialog prompts with the minimum required functionality and smart defaults.
+ +Be sure not to open a modal while another is still visible. Showing more than one modal at a time requires custom code.
+Always try to place a modal's HTML code in a top-level position in your document to avoid other components affecting the modal's appearance and/or functionality.
+There are some caveats regarding using modals on mobile devices. See our browser support docs for details.
+A rendered modal with header, body, and set of actions in the footer.
+Toggle a modal via JavaScript by clicking the button below. It will slide down and fade in from the top of the page.
+ + + +Be sure to add role="dialog"
to .modal
, aria-labelledby="myModalLabel"
attribute to reference the modal title, and aria-hidden="true"
to tell assistive technologies to skip the modal's DOM elements.
Additionally, you may give a description of your modal dialog with aria-describedby
on .modal
.
Embedding YouTube videos in modals requires additional JavaScript not in Bootstrap to automatically stop playback and more. See this helpful Stack Overflow post for more information.
+Modals have two optional sizes, available via modifier classes to be placed on a .modal-dialog
.
For modals that simply appear rather than fade in to view, remove the .fade
class from your modal markup.
The modal plugin toggles your hidden content on demand, via data attributes or JavaScript. It also adds .modal-open
to the <body>
to override default scrolling behavior and generates a .modal-backdrop
to provide a click area for dismissing shown modals when clicking outside the modal.
Activate a modal without writing JavaScript. Set data-toggle="modal"
on a controller element, like a button, along with a data-target="#foo"
or href="#foo"
to target a specific modal to toggle.
Call a modal with id myModal
with a single line of JavaScript:
Options can be passed via data attributes or JavaScript. For data attributes, append the option name to data-
, as in data-backdrop=""
.
Name | +type | +default | +description | +
---|---|---|---|
backdrop | +boolean or the string 'static' |
+ true | +Includes a modal-backdrop element. Alternatively, specify static for a backdrop which doesn't close the modal on click. |
+
keyboard | +boolean | +true | +Closes the modal when escape key is pressed | +
show | +boolean | +true | +Shows the modal when initialized. | +
remote | +path | +false | +If a remote URL is provided, content will be loaded one time via jQuery's |
+
Activates your content as a modal. Accepts an optional options object
.
Manually toggles a modal. Returns to the caller before the modal has actually been shown or hidden (i.e. before the shown.bs.modal
or hidden.bs.modal
event occurs).
Manually opens a modal. Returns to the caller before the modal has actually been shown (i.e. before the shown.bs.modal
event occurs).
Manually hides a modal. Returns to the caller before the modal has actually been hidden (i.e. before the hidden.bs.modal
event occurs).
Bootstrap's modal class exposes a few events for hooking into modal functionality.
+Event Type | +Description | +
---|---|
show.bs.modal | +This event fires immediately when the show instance method is called. If caused by a click, the clicked element is available as the relatedTarget property of the event. |
+
shown.bs.modal | +This event is fired when the modal has been made visible to the user (will wait for CSS transitions to complete). If caused by a click, the clicked element is available as the relatedTarget property of the event. |
+
hide.bs.modal | +This event is fired immediately when the hide instance method has been called. |
+
hidden.bs.modal | +This event is fired when the modal has finished being hidden from the user (will wait for CSS transitions to complete). | +
loaded.bs.modal | +This event is fired when the modal has loaded content using the remote option. | +
Plugins can be included individually (using Bootstrap's individual *.js
files), or all at once (using bootstrap.js
or the minified bootstrap.min.js
).
Both bootstrap.js
and bootstrap.min.js
contain all plugins in a single file. Include only one.
Don't use data attributes from multiple plugins on the same element. For example, a button cannot both have a tooltip and toggle a modal. To accomplish this, use a wrapping element.
+Some plugins and CSS components depend on other plugins. If you include plugins individually, make sure to check for these dependencies in the docs. Also note that all plugins depend on jQuery (this means jQuery must be included before the plugin files). Consult our bower.json
to see which versions of jQuery are supported.
You can use all Bootstrap plugins purely through the markup API without writing a single line of JavaScript. This is Bootstrap's first-class API and should be your first consideration when using a plugin.
+ +That said, in some situations it may be desirable to turn this functionality off. Therefore, we also provide the ability to disable the data attribute API by unbinding all events on the document namespaced with data-api
. This looks like this:
Alternatively, to target a specific plugin, just include the plugin's name as a namespace along with the data-api namespace like this:
+{% highlight js %} +$(document).off('.alert.data-api') +{% endhighlight %} + +We also believe you should be able to use all Bootstrap plugins purely through the JavaScript API. All public APIs are single, chainable methods, and return the collection acted upon.
+{% highlight js %} +$('.btn.danger').button('toggle').addClass('fat') +{% endhighlight %} + +All methods should accept an optional options object, a string which targets a particular method, or nothing (which initiates a plugin with default behavior):
+{% highlight js %} +$('#myModal').modal() // initialized with defaults +$('#myModal').modal({ keyboard: false }) // initialized with no keyboard +$('#myModal').modal('show') // initializes and invokes show immediately +{% endhighlight %} + +Each plugin also exposes its raw constructor on a Constructor
property: $.fn.popover.Constructor
. If you'd like to get a particular plugin instance, retrieve it directly from an element: $('[rel=popover]').data('popover')
.
Sometimes it is necessary to use Bootstrap plugins with other UI frameworks. In these circumstances, namespace collisions can occasionally occur. If this happens, you may call .noConflict
on the plugin you wish to revert the value of.
Bootstrap provides custom events for most plugins' unique actions. Generally, these come in an infinitive and past participle form - where the infinitive (ex. show
) is triggered at the start of an event, and its past participle form (ex. shown
) is triggered on the completion of an action.
As of 3.0.0, all Bootstrap events are namespaced.
+All infinitive events provide preventDefault
functionality. This provides the ability to stop the execution of an action before it starts.
Bootstrap does not officially support third-party JavaScript libraries like Prototype or jQuery UI. Despite .noConflict
and namespaced events, there may be compatibility problems that you need to fix on your own.
Add small overlays of content, like those on the iPad, to any element for housing secondary information.
+ +Popovers require the tooltip plugin to be included in your version of Bootstrap.
+For performance reasons, the Tooltip and Popover data-apis are opt-in, meaning you must initialize them yourself.
+When using popovers on elements within a .btn-group
or an .input-group
, you'll have to specify the option container: 'body'
(documented below) to avoid unwanted side effects (such as the element growing wider and/or losing its rounded corners when the popover is triggered).
To add a popover to a disabled
or .disabled
element, put the element inside of a <div>
and apply the popover to that <div>
instead.
Four options are available: top, right, bottom, and left aligned.
+Sed posuere consectetur est at lobortis. Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum.
+Sed posuere consectetur est at lobortis. Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum.
+Sed posuere consectetur est at lobortis. Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum.
+Sed posuere consectetur est at lobortis. Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum.
+Use the focus
trigger to dismiss popovers on their next click.
Sometimes you want to add a popover to a hyperlink that wraps multiple lines. The default behavior of the popover plugin is to center it horizontally and vertically. Add white-space: nowrap;
to your anchors to avoid this.
Enable popovers via JavaScript:
+ {% highlight js %}$('#example').popover(options){% endhighlight %} + +Options can be passed via data attributes or JavaScript. For data attributes, append the option name to data-
, as in data-animation=""
.
Name | +type | +default | +description | +
---|---|---|---|
animation | +boolean | +true | +apply a CSS fade transition to the popover | +
html | +boolean | +false | +Insert HTML into the popover. If false, jQuery's text method will be used to insert content into the DOM. Use text if you're worried about XSS attacks. |
+
placement | +string | function | +'right' | +how to position the popover - top | bottom | left | right | auto. When "auto" is specified, it will dynamically reorient the popover. For example, if placement is "auto left", the popover will display to the left when possible, otherwise it will display right. |
+
selector | +string | +false | +if a selector is provided, popover objects will be delegated to the specified targets. In practice, this is used to enable dynamic HTML content to have popovers added. See this and an informative example. | +
trigger | +string | +'click' | +how popover is triggered - click | hover | focus | manual | +
title | +string | function | +'' | +default title value if title attribute isn't present |
+
content | +string | function | +'' | +default content value if data-content attribute isn't present |
+
delay | +number | object | +0 | +
+ delay showing and hiding the popover (ms) - does not apply to manual trigger type +If a number is supplied, delay is applied to both hide/show +Object structure is: |
+
container | +string | false | +false | +
+ Appends the popover to a specific element. Example: |
+
Options for individual popovers can alternatively be specified through the use of data attributes, as explained above.
+Initializes popovers for an element collection.
+ +Reveals an elements popover.
+ {% highlight js %}$('#element').popover('show'){% endhighlight %} + +Hides an elements popover.
+ {% highlight js %}$('#element').popover('hide'){% endhighlight %} + +Toggles an elements popover.
+ {% highlight js %}$('#element').popover('toggle'){% endhighlight %} + +Hides and destroys an element's popover.
+ {% highlight js %}$('#element').popover('destroy'){% endhighlight %} +Event Type | +Description | +
---|---|
show.bs.popover | +This event fires immediately when the show instance method is called. |
+
shown.bs.popover | +This event is fired when the popover has been made visible to the user (will wait for CSS transitions to complete). | +
hide.bs.popover | +This event is fired immediately when the hide instance method has been called. |
+
hidden.bs.popover | +This event is fired when the popover has finished being hidden from the user (will wait for CSS transitions to complete). | +
Add dismiss functionality to all alert messages with this plugin.
+Change this and that and try again. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit. Cras mattis consectetur purus sit amet fermentum.
++ + +
+Enable dismissal of an alert via JavaScript:
+ {% highlight js %}$(".alert").alert(){% endhighlight %} + +Just add data-dismiss="alert"
to your close button to automatically give an alert close functionality.
Wraps all alerts with close functionality. To have your alerts animate out when closed, make sure they have the .fade
and .in
class already applied to them.
Closes an alert.
+ {% highlight js %}$(".alert").alert('close'){% endhighlight %} + + +Bootstrap's alert class exposes a few events for hooking into alert functionality.
+Event Type | +Description | +
---|---|
close.bs.alert | +This event fires immediately when the close instance method is called. |
+
closed.bs.alert | +This event is fired when the alert has been closed (will wait for CSS transitions to complete). | +
The ScrollSpy plugin is for automatically updating nav targets based on scroll position. Scroll the area below the navbar and watch the active class change. The dropdown sub items will be highlighted as well.
+Ad leggings keytar, brunch id art party dolor labore. Pitchfork yr enim lo-fi before they sold out qui. Tumblr farm-to-table bicycle rights whatever. Anim keffiyeh carles cardigan. Velit seitan mcsweeney's photo booth 3 wolf moon irure. Cosby sweater lomo jean shorts, williamsburg hoodie minim qui you probably haven't heard of them et cardigan trust fund culpa biodiesel wes anderson aesthetic. Nihil tattooed accusamus, cred irony biodiesel keffiyeh artisan ullamco consequat.
+Veniam marfa mustache skateboard, adipisicing fugiat velit pitchfork beard. Freegan beard aliqua cupidatat mcsweeney's vero. Cupidatat four loko nisi, ea helvetica nulla carles. Tattooed cosby sweater food truck, mcsweeney's quis non freegan vinyl. Lo-fi wes anderson +1 sartorial. Carles non aesthetic exercitation quis gentrify. Brooklyn adipisicing craft beer vice keytar deserunt.
+Occaecat commodo aliqua delectus. Fap craft beer deserunt skateboard ea. Lomo bicycle rights adipisicing banh mi, velit ea sunt next level locavore single-origin coffee in magna veniam. High life id vinyl, echo park consequat quis aliquip banh mi pitchfork. Vero VHS est adipisicing. Consectetur nisi DIY minim messenger bag. Cred ex in, sustainable delectus consectetur fanny pack iphone.
+In incididunt echo park, officia deserunt mcsweeney's proident master cleanse thundercats sapiente veniam. Excepteur VHS elit, proident shoreditch +1 biodiesel laborum craft beer. Single-origin coffee wayfarers irure four loko, cupidatat terry richardson master cleanse. Assumenda you probably haven't heard of them art party fanny pack, tattooed nulla cardigan tempor ad. Proident wolf nesciunt sartorial keffiyeh eu banh mi sustainable. Elit wolf voluptate, lo-fi ea portland before they sold out four loko. Locavore enim nostrud mlkshk brooklyn nesciunt.
+Ad leggings keytar, brunch id art party dolor labore. Pitchfork yr enim lo-fi before they sold out qui. Tumblr farm-to-table bicycle rights whatever. Anim keffiyeh carles cardigan. Velit seitan mcsweeney's photo booth 3 wolf moon irure. Cosby sweater lomo jean shorts, williamsburg hoodie minim qui you probably haven't heard of them et cardigan trust fund culpa biodiesel wes anderson aesthetic. Nihil tattooed accusamus, cred irony biodiesel keffiyeh artisan ullamco consequat.
+Keytar twee blog, culpa messenger bag marfa whatever delectus food truck. Sapiente synth id assumenda. Locavore sed helvetica cliche irony, thundercats you probably haven't heard of them consequat hoodie gluten-free lo-fi fap aliquip. Labore elit placeat before they sold out, terry richardson proident brunch nesciunt quis cosby sweater pariatur keffiyeh ut helvetica artisan. Cardigan craft beer seitan readymade velit. VHS chambray laboris tempor veniam. Anim mollit minim commodo ullamco thundercats. +
+No matter the implementation method, scrollspy requires the use of position: relative;
on the element you're spying on. In most cases this is the <body>
.
To easily add scrollspy behavior to your topbar navigation, add data-spy="scroll"
to the element you want to spy on (most typically this would be the <body>
). Then add the data-target
attribute with the ID or class of the parent element of any Bootstrap .nav
component.
After adding position: relative;
in your CSS, call the scrollspy via JavaScript:
Navbar links must have resolvable id targets. For example, a <a href="#home">home</a>
must correspond to something in the DOM like <div id="home"></div>
.
When using scrollspy in conjunction with adding or removing of elements from the DOM, you'll need to call the refresh method like so:
+{% highlight js %} +$('[data-spy="scroll"]').each(function () { + var $spy = $(this).scrollspy('refresh') +}) +{% endhighlight %} + + +Options can be passed via data attributes or JavaScript. For data attributes, append the option name to data-
, as in data-offset=""
.
Name | +type | +default | +description | +
---|---|---|---|
offset | +number | +10 | +Pixels to offset from top when calculating position of scroll. | +
Event Type | +Description | +
---|---|
activate.bs.scrollspy | +This event fires whenever a new item becomes activated by the scrollspy. | +
Add quick, dynamic tab functionality to transition through panes of local content, even via dropdown menus.
+Raw denim you probably haven't heard of them jean shorts Austin. Nesciunt tofu stumptown aliqua, retro synth master cleanse. Mustache cliche tempor, williamsburg carles vegan helvetica. Reprehenderit butcher retro keffiyeh dreamcatcher synth. Cosby sweater eu banh mi, qui irure terry richardson ex squid. Aliquip placeat salvia cillum iphone. Seitan aliquip quis cardigan american apparel, butcher voluptate nisi qui.
+Food truck fixie locavore, accusamus mcsweeney's marfa nulla single-origin coffee squid. Exercitation +1 labore velit, blog sartorial PBR leggings next level wes anderson artisan four loko farm-to-table craft beer twee. Qui photo booth letterpress, commodo enim craft beer mlkshk aliquip jean shorts ullamco ad vinyl cillum PBR. Homo nostrud organic, assumenda labore aesthetic magna delectus mollit. Keytar helvetica VHS salvia yr, vero magna velit sapiente labore stumptown. Vegan fanny pack odio cillum wes anderson 8-bit, sustainable jean shorts beard ut DIY ethical culpa terry richardson biodiesel. Art party scenester stumptown, tumblr butcher vero sint qui sapiente accusamus tattooed echo park.
+Etsy mixtape wayfarers, ethical wes anderson tofu before they sold out mcsweeney's organic lomo retro fanny pack lo-fi farm-to-table readymade. Messenger bag gentrify pitchfork tattooed craft beer, iphone skateboard locavore carles etsy salvia banksy hoodie helvetica. DIY synth PBR banksy irony. Leggings gentrify squid 8-bit cred pitchfork. Williamsburg banh mi whatever gluten-free, carles pitchfork biodiesel fixie etsy retro mlkshk vice blog. Scenester cred you probably haven't heard of them, vinyl craft beer blog stumptown. Pitchfork sustainable tofu synth chambray yr.
+Trust fund seitan letterpress, keytar raw denim keffiyeh etsy art party before they sold out master cleanse gluten-free squid scenester freegan cosby sweater. Fanny pack portland seitan DIY, art party locavore wolf cliche high life echo park Austin. Cred vinyl keffiyeh DIY salvia PBR, banh mi before they sold out farm-to-table VHS viral locavore cosby sweater. Lomo wolf viral, mustache readymade thundercats keffiyeh craft beer marfa ethical. Wolf salvia freegan, sartorial keffiyeh echo park vegan.
+This plugin extends the tabbed navigation component to add tabbable areas.
+Enable tabbable tabs via JavaScript (each tab needs to be activated individually):
+ +{% highlight js %} +$('#myTab a').click(function (e) { + e.preventDefault() + $(this).tab('show') +}) +{% endhighlight %} + +You can activate individual tabs in several ways:
+ +{% highlight js %} +$('#myTab a[href="#profile"]').tab('show') // Select tab by name +$('#myTab a:first').tab('show') // Select first tab +$('#myTab a:last').tab('show') // Select last tab +$('#myTab li:eq(2) a').tab('show') // Select third tab (0-indexed) +{% endhighlight %} + +You can activate a tab or pill navigation without writing any JavaScript by simply specifying data-toggle="tab"
or data-toggle="pill"
on an element. Adding the nav
and nav-tabs
classes to the tab ul
will apply the Bootstrap tab styling, while adding the nav
and nav-pills
classes will apply pill styling.
To make tabs fade in, add .fade
to each .tab-pane
. The first tab pane must also have .in
to properly fade in initial content.
+ Activates a tab element and content container. Tab should have either a data-target
or an href
targeting a container node in the DOM.
+
Event Type | +Description | +
---|---|
show.bs.tab | +This event fires on tab show, but before the new tab has been shown. Use event.target and event.relatedTarget to target the active tab and the previous active tab (if available) respectively. |
+
shown.bs.tab | +This event fires on tab show after a tab has been shown. Use event.target and event.relatedTarget to target the active tab and the previous active tab (if available) respectively. |
+
Inspired by the excellent jQuery.tipsy plugin written by Jason Frame; Tooltips are an updated version, which don't rely on images, use CSS3 for animations, and data-attributes for local title storage.
+Hover over the links below to see tooltips:
+Tight pants next level keffiyeh you probably haven't heard of them. Photo booth beard raw denim letterpress vegan messenger bag stumptown. Farm-to-table seitan, mcsweeney's fixie sustainable quinoa 8-bit american apparel have a terry richardson vinyl chambray. Beard stumptown, cardigans banh mi lomo thundercats. Tofu biodiesel williamsburg marfa, four loko mcsweeney's cleanse vegan chambray. A really ironic artisan whatever keytar, scenester farm-to-table banksy Austin twitter handle freegan cred raw denim single-origin coffee viral. +
+For performance reasons, the Tooltip and Popover data-apis are opt-in, meaning you must initialize them yourself.
+When using tooltips on elements within a .btn-group
or an .input-group
, you'll have to specify the option container: 'body'
(documented below) to avoid unwanted side effects (such as the element growing wider and/or losing its rounded corners when the tooltip is triggered).
To add a tooltip to a disabled
or .disabled
element, put the element inside of a <div>
and apply the tooltip to that <div>
instead.
The tooltip plugin generates content and markup on demand, and by default places tooltips after their trigger element.
+Trigger the tooltip via JavaScript:
+{% highlight js %} +$('#example').tooltip(options) +{% endhighlight %} + +The required markup for a tooltip is only a data
attribute and title
on the HTML element you wish to have a tooltip. The generated markup of a tooltip is rather simple, though it does require a position (by default, set to top
by the plugin).
Sometimes you want to add a tooltip to a hyperlink that wraps multiple lines. The default behavior of the tooltip plugin is to center it horizontally and vertically. Add white-space: nowrap;
to your anchors to avoid this.
Options can be passed via data attributes or JavaScript. For data attributes, append the option name to data-
, as in data-animation=""
.
Name | +type | +default | +description | +
---|---|---|---|
animation | +boolean | +true | +apply a CSS fade transition to the tooltip | +
html | +boolean | +false | +Insert HTML into the tooltip. If false, jQuery's text method will be used to insert content into the DOM. Use text if you're worried about XSS attacks. |
+
placement | +string | function | +'top' | +how to position the tooltip - top | bottom | left | right | auto. When "auto" is specified, it will dynamically reorient the tooltip. For example, if placement is "auto left", the tooltip will display to the left when possible, otherwise it will display right. |
+
selector | +string | +false | +If a selector is provided, tooltip objects will be delegated to the specified targets. | +
title | +string | function | +'' | +default title value if title attribute isn't present |
+
trigger | +string | +'hover focus' | +how tooltip is triggered - click | hover | focus | manual. You may pass multiple triggers; separate them with a space. | +
delay | +number | object | +0 | +
+ delay showing and hiding the tooltip (ms) - does not apply to manual trigger type +If a number is supplied, delay is applied to both hide/show +Object structure is: |
+
container | +string | false | +false | +
+ Appends the tooltip to a specific element. Example: |
+
Options for individual tooltips can alternatively be specified through the use of data attributes, as explained above.
+Attaches a tooltip handler to an element collection.
+ +Reveals an element's tooltip.
+ {% highlight js %}$('#element').tooltip('show'){% endhighlight %} + +Hides an element's tooltip.
+ {% highlight js %}$('#element').tooltip('hide'){% endhighlight %} + +Toggles an element's tooltip.
+ {% highlight js %}$('#element').tooltip('toggle'){% endhighlight %} + +Hides and destroys an element's tooltip.
+ {% highlight js %}$('#element').tooltip('destroy'){% endhighlight %} + +Event Type | +Description | +
---|---|
show.bs.tooltip | +This event fires immediately when the show instance method is called. |
+
shown.bs.tooltip | +This event is fired when the tooltip has been made visible to the user (will wait for CSS transitions to complete). | +
hide.bs.tooltip | +This event is fired immediately when the hide instance method has been called. |
+
hidden.bs.tooltip | +This event is fired when the tooltip has finished being hidden from the user (will wait for CSS transitions to complete). | +
For simple transition effects, include transition.js
once alongside the other JS files. If you're using the compiled (or minified) bootstrap.js
, there is no need to include this—it's already there.
Transition.js is a basic helper for transitionEnd
events as well as a CSS transition emulator. It's used by the other plugins to check for CSS transition support and to catch hanging transitions.
{content}
in '+m+" ";var n=function(a,c,d){a.extract[c]!==b&&k.push(i.replace(/\{line\}/,(parseInt(a.line,10)||0)+(c-1)).replace(/\{class\}/,d).replace(/\{content\}/,a.extract[c]))};a.extract?(n(a,0,""),n(a,1,"line"),n(a,2,""),f+="on line "+a.line+", column "+(a.column+1)+":
Includes 200 glyphs in font format from the Glyphicon Halflings set. Glyphicons Halflings are normally not available for free, but their creator has made them available for Bootstrap free of cost. As a thank you, we only ask that you include a link back to Glyphicons whenever possible.
-For performance reasons, all icons require a base class and individual icon class. To use, place the following code just about anywhere. Be sure to leave a space between the icon and text for proper padding.
-Icon classes cannot be directly combined with other components. They should not be used along with other classes on the same element. Instead, add a nested <span>
and apply the icon classes to the <span>
.
Use them in buttons, button groups for a toolbar, navigation, or prepended form inputs.
-Toggleable, contextual menu for displaying lists of links. Made interactive with the dropdown JavaScript plugin.
- -Wrap the dropdown's trigger and the dropdown menu within .dropdown
, or another element that declares position: relative;
. Then add the menu's HTML.
By default, a dropdown menu is automatically positioned 100% from the top and along the left side of its parent. Add .dropdown-menu-right
to a .dropdown-menu
to right align the dropdown menu.
Dropdowns are automatically positioned via CSS within the normal flow of the document. This means dropdowns may be cropped by parents with certain overflow
properties or appear out of bounds of the viewport. Address these issues on your own as they arise.
.pull-right
alignmentAs of v3.1.0, we've deprecated .pull-right
on dropdown menus. To right-align a menu, use .dropdown-menu-right
. Right-aligned nav components in the navbar use a mixin version of this class to automatically align the menu. To override it, use .dropdown-menu-left
.
Add a header to label sections of actions in any dropdown menu.
-Add .disabled
to a <li>
in the dropdown to disable the link.
Group a series of buttons together on a single line with the button group. Add on optional JavaScript radio and checkbox style behavior with our buttons plugin.
- -When using tooltips or popovers on elements within a .btn-group
, you'll have to specify the option container: 'body'
to avoid unwanted side effects (such as the element growing wider and/or losing its rounded corners when the tooltip or popover is triggered).
Wrap a series of buttons with .btn
in .btn-group
.
Combine sets of <div class="btn-group">
into a <div class="btn-toolbar">
for more complex components.
Instead of applying button sizing classes to every button in a group, just add .btn-group-*
to the .btn-group
.
Place a .btn-group
within another .btn-group
when you want dropdown menus mixed with a series of buttons.
Make a set of buttons appear vertically stacked rather than horizontally. Split button dropdowns are not supported here.
-Make a group of buttons stretch at equal sizes to span the entire width of its parent. Also works with button dropdowns within the button group.
- -Due to the specific HTML and CSS used to justify buttons (namely display: table-cell
), the borders between them are doubled. In regular button groups, margin-left: -1px
is used to stack the borders instead of removing them. However, margin
doesn't work with display: table-cell
. As a result, depending on your customizations to Bootstrap, you may wish to remove or re-color the borders.
Internet Explorer 8 doesn't render borders in on buttons in a justified button group, whether it's on <a>
or <button>
elements. To get around that, wrap each button in another .btn-group
.
See #12476 for more information.
-<a>
elementsJust wrap a series of .btn
s in .btn-group.btn-group-justified
.
<button>
elementsTo use justified button groups with <button>
elements, you must wrap each button in a button group. Most browsers don't properly apply our CSS for justification to <button>
elements, but since we support button dropdowns, we can workaround that.
Use any button to trigger a dropdown menu by placing it within a .btn-group
and providing the proper menu markup.
Button dropdowns require the dropdown plugin to be included in your version of Bootstrap.
-Turn a button into a dropdown toggle with some basic markup changes.
-Similarly, create split button dropdowns with the same markup changes, only with a separate button.
-Button dropdowns work with buttons of all sizes.
-Trigger dropdown menus above elements by adding .dropup
to the parent.
Extend form controls by adding text or buttons before, after, or on both sides of any text-based input. Use .input-group
with an .input-group-addon
to prepend or append elements to a single .form-control
.
Avoid using <select>
elements here as they cannot be fully styled in WebKit browsers.
When using tooltips or popovers on elements within an .input-group
, you'll have to specify the option container: 'body'
to avoid unwanted side effects (such as the element growing wider and/or losing its rounded corners when the tooltip or popover is triggered).
Do not mix form groups or grid column classes directly with input groups. Instead, nest the input group inside of the form group or grid-related element.
-Place one add-on or button on either side of an input. You may also place one on both sides of an input.
-We do not support multiple add-ons on a single side.
-We do not support multiple form-controls in a single input group.
- -{% highlight html %} -Add the relative form sizing classes to the .input-group
itself and contents within will automatically resize—no need for repeating the form control size classes on each element.
Place any checkbox or radio option within an input group's addon instead of text.
- -{% highlight html %} -Buttons in input groups are a bit different and require one extra level of nesting. Instead of .input-group-addon
, you'll need to use .input-group-btn
to wrap the buttons. This is required due to default browser styles that cannot be overridden.
Navs available in Bootstrap have shared markup, starting with the base .nav
class, as well as shared states. Swap modifier classes to switch between each style.
Note the .nav-tabs
class requires the .nav
base class.
For tabs with tabbable areas, you must use the tabs JavaScript plugin.
-Take that same HTML, but use .nav-pills
instead:
Pills are also vertically stackable. Just add .nav-stacked
.
Easily make tabs or pills equal widths of their parent at screens wider than 768px with .nav-justified
. On smaller screens, the nav links are stacked.
As of v7.0.1, Safari exhibits a bug in which resizing your browser horizontally causes rendering errors in the justified nav that are cleared upon refreshing. This bug is also shown in the justified nav example.
-For any nav component (tabs or pills), add .disabled
for gray links and no hover effects.
This class will only change the <a>
's appearance, not its functionality. Use custom JavaScript to disable links here.
Add dropdown menus with a little extra HTML and the dropdowns JavaScript plugin.
- -Navbars are responsive meta components that serve as navigation headers for your application or site. They begin collapsed (and are toggleable) in mobile views and become horizontal as the available viewport width increases.
- - -If JavaScript is disabled and the viewport is narrow enough that the navbar collapses, it will be impossible to expand the navbar and view the content within the .navbar-collapse
.
The responsive navbar requires the collapse plugin to be included in your version of Bootstrap.
-Be sure to add a role="navigation"
to every navbar to help with accessibility.
Place form content within .navbar-form
for proper vertical alignment and collapsed behavior in narrow viewports. Use the alignment options to decide where it resides within the navbar content.
As a heads up, .navbar-form
shares much of its code with .form-inline
via mixin. Some form controls, like input groups, may require fixed widths to be show up properly within a navbar.
There are some caveats regarding using form controls within fixed elements on mobile devices. See our browser support docs for details.
-Screen readers will have trouble with your forms if you don't include a label for every input. For these inline navbar forms, you can hide the labels using the .sr-only
class.
Add the .navbar-btn
class to <button>
elements not residing in a <form>
to vertically center them in the navbar.
Like the standard button classes, .navbar-btn
can be used on <a>
and <input>
elements. However, neither .navbar-btn
nor the standard button classes should be used on <a>
elements within .navbar-nav
.
Wrap strings of text in an element with .navbar-text
, usually on a <p>
tag for proper leading and color.
For folks using standard links that are not within the regular navbar navigation component, use the .navbar-link
class to add the proper colors for the default and inverse navbar options.
Align nav links, forms, buttons, or text, using the .navbar-left
or .navbar-right
utility classes. Both classes will add a CSS float in the specified direction. For example, to align nav links, put them in a separate <ul>
with the respective utility class applied.
These classes are mixin-ed versions of .pull-left
and .pull-right
, but they're scoped to media queries for easier handling of navbar components across device sizes.
Navbars currently have a limitation with multiple .navbar-right
classes. To properly space content, we use negative margin on the last .navbar-right
element. When there are multiple elements using that class, these margins don't work as intended.
We'll revisit this when we can rewrite that component in v4.
-Add .navbar-fixed-top
and include a .container
or .container-fluid
to center and pad navbar content.
The fixed navbar will overlay your other content, unless you add padding
to the top of the <body>
. Try out your own values or use our snippet below. Tip: By default, the navbar is 50px high.
Make sure to include this after the core Bootstrap CSS.
-Add .navbar-fixed-bottom
and include a .container
or .container-fluid
to center and pad navbar content.
The fixed navbar will overlay your other content, unless you add padding
to the bottom of the <body>
. Try out your own values or use our snippet below. Tip: By default, the navbar is 50px high.
Make sure to include this after the core Bootstrap CSS.
-Create a full-width navbar that scrolls away with the page by adding .navbar-static-top
and include a .container
or .container-fluid
to center and pad navbar content.
Unlike the .navbar-fixed-*
classes, you do not need to change any padding on the body
.
Modify the look of the navbar by adding .navbar-inverse
.
Indicate the current page's location within a navigational hierarchy.
-Separators are automatically added in CSS through :before
and content
.
Provide pagination links for your site or app with the multi-page pagination component, or the simpler pager alternative.
- -Simple pagination inspired by Rdio, great for apps and search results. The large block is hard to miss, easily scalable, and provides large click areas.
- -{% highlight html %} - -{% endhighlight %} - -Links are customizable for different circumstances. Use .disabled
for unclickable links and .active
to indicate the current page.
You can optionally swap out active or disabled anchors for <span>
to remove click functionality while retaining intended styles.
Fancy larger or smaller pagination? Add .pagination-lg
or .pagination-sm
for additional sizes.
Quick previous and next links for simple pagination implementations with light markup and styles. It's great for simple sites like blogs or magazines.
- -By default, the pager centers links.
- -{% highlight html %} - -{% endhighlight %} - -Alternatively, you can align each link to the sides:
- -{% highlight html %} - -{% endhighlight %} - - -Pager links also use the general .disabled
utility class from the pagination.
Add any of the below mentioned modifier classes to change the appearance of a label.
-Easily highlight new or unread items by adding a <span class="badge">
to links, Bootstrap navs, and more.
When there are no new or unread items, badges will simply collapse (via CSS's :empty
selector) provided no content exists within.
Badges won't self collapse in Internet Explorer 8 because it lacks support for the :empty
selector.
Built-in styles are included for placing badges in active states in pill navigations.
-A lightweight, flexible component that can optionally extend the entire viewport to showcase key content on your site.
-This is a simple hero unit, a simple jumbotron-style component for calling extra attention to featured content or information.
- -To make the jumbotron full width, and without rounded corners, place it outside all .container
s and instead add a .container
within.
A simple shell for an h1
to appropriately space out and segment sections of content on a page. It can utilize the h1
's default small
element, as well as most other components (with additional styles).
Extend Bootstrap's grid system with the thumbnail component to easily display grids of images, videos, text, and more.
- -By default, Bootstrap's thumbnails are designed to showcase linked images with minimal required markup.
- -{% highlight html %} -With a bit of extra markup, it's possible to add any kind of HTML content like headings, paragraphs, or buttons into thumbnails.
-Provide contextual feedback messages for typical user actions with the handful of available and flexible alert messages. For inline dismissal, use the alerts jQuery plugin.
- -Wrap any text and an optional dismiss button in .alert
and one of the four contextual classes (e.g., .alert-success
) for basic alert messages.
Alerts don't have default classes, only base and modifier classes. A default gray alert doesn't make too much sense, so you're required to specify a type via contextual class. Choose from success, info, warning, or danger.
-Build on any alert by adding an optional .alert-dismissable
and close button.
Be sure to use the <button>
element with the data-dismiss="alert"
data attribute.
Use the .alert-link
utility class to quickly provide matching colored links within any alert.
Provide up-to-date feedback on the progress of a workflow or action with simple yet flexible progress bars.
- -Progress bars use CSS3 transitions and animations to achieve some of their effects. These features are not supported in Internet Explorer 9 and below or older versions of Firefox. Opera 12 does not support animations.
-Default progress bar.
-Remove the .sr-only
class from within the progress bar to show a visible percentage. For low percentages, consider adding a min-width
to ensure the label's text is fully visible.
Progress bars representing low single digit percentages, as well as 0%, include a min-width: 20px;
for legibility.
Progress bars use some of the same button and alert classes for consistent styles.
-Uses a gradient to create a striped effect. Not available in IE8.
-Add .active
to .progress-striped
to animate the stripes right to left. Not available in IE9 and below.
Place multiple bars into the same .progress
to stack them.
Abstract object styles for building various types of components (like blog comments, Tweets, etc) that feature a left- or right-aligned image alongside textual content.
- -The default media allow to float a media object (images, video, audio) to the left or right of a content block.
-With a bit of extra markup, you can use media inside list (useful for comment threads or articles lists).
-Cras sit amet nibh libero, in gravida nulla. Nulla vel metus scelerisque ante sollicitudin commodo. Cras purus odio, vestibulum in vulputate at, tempus viverra turpis.
- -List groups are a flexible and powerful component for displaying not only simple lists of elements, but complex ones with custom content.
- -The most basic list group is simply an unordered list with list items, and the proper classes. Build upon it with the options that follow, or your own CSS as needed.
-Add the badges component to any list group item and it will automatically be positioned on the right.
-Linkify list group items by using anchor tags instead of list items (that also means a parent <div>
instead of an <ul>
). No need for individual parents around each element.
Add .disabled
to a .list-group-item
to gray it out to appear disabled.
Use contextual classes to style list items, default or linked. Also includes .active
state.
Add nearly any HTML within, even for linked list groups like the one below.
-Donec id elit non mi porta gravida at eget metus. Maecenas sed diam eget risus varius blandit.
- - -Donec id elit non mi porta gravida at eget metus. Maecenas sed diam eget risus varius blandit.
- - -Donec id elit non mi porta gravida at eget metus. Maecenas sed diam eget risus varius blandit.
- -While not always necessary, sometimes you need to put your DOM in a box. For those situations, try the panel component.
- -By default, all the .panel
does is apply some basic border and padding to contain some content.
Easily add a heading container to your panel with .panel-heading
. You may also include any <h1>
-<h6>
with a .panel-title
class to add a pre-styled heading.
Wrap buttons or secondary text in .panel-footer
. Note that panel footers do not inherit colors and borders when using contextual variations as they are not meant to be in the foreground.
Like other components, easily make a panel more meaningful to a particular context by adding any of the contextual state classes.
-Add any non-bordered .table
within a panel for a seamless design. If there is a .panel-body
, we add an extra border to the top of the table for separation.
Some default panel content here. Nulla vitae elit libero, a pharetra augue. Aenean lacinia bibendum nulla sed consectetur. Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum. Nullam id dolor id nibh ultricies vehicula ut id elit.
-# | -First Name | -Last Name | -Username | -
---|---|---|---|
1 | -Mark | -Otto | -@mdo | -
2 | -Jacob | -Thornton | -@fat | -
3 | -Larry | -the Bird | -
...
-If there is no panel body, the component moves from panel header to table without interruption.
-# | -First Name | -Last Name | -Username | -
---|---|---|---|
1 | -Mark | -Otto | -@mdo | -
2 | -Jacob | -Thornton | -@fat | -
3 | -Larry | -the Bird | -
Easily include full-width list groups within any panel.
-Some default panel content here. Nulla vitae elit libero, a pharetra augue. Aenean lacinia bibendum nulla sed consectetur. Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum. Nullam id dolor id nibh ultricies vehicula ut id elit.
-...
-Allow browsers to determine video or slideshow dimensions based on the width of their containing block by creating an intrinsic ratio that will properly scale on any device.
-Rules are directly apply to <iframe>
, <embed>
and <object>
elements, optionally use of an explicit descendant class .embed-responsive-item
when you want to match the styling for other attributes.
Pro-Tip! You don't need to include frameborder="0"
in your <iframe>
s as we override that for you.
Use the well as a simple effect on an element to give it an inset effect.
-Control padding and rounded corners with two optional modifier classes.
-Get the lowdown on the key pieces of Bootstrap's infrastructure, including our approach to better, faster, stronger web development.
- -Bootstrap makes use of certain HTML elements and CSS properties that require the use of the HTML5 doctype. Include it at the beginning of all your projects.
-{% highlight html %} - - - ... - -{% endhighlight %} - -With Bootstrap 2, we added optional mobile friendly styles for key aspects of the framework. With Bootstrap 3, we've rewritten the project to be mobile friendly from the start. Instead of adding on optional mobile styles, they're baked right into the core. In fact, Bootstrap is mobile first. Mobile first styles can be found throughout the entire library instead of in separate files.
-To ensure proper rendering and touch zooming, add the viewport meta tag to your <head>
.
You can disable zooming capabilities on mobile devices by adding user-scalable=no
to the viewport meta tag. This disables zooming, meaning users are only able to scroll, and results in your site feeling a bit more like a native application. Overall, we don't recommend this on every site, so use caution!
Bootstrap sets basic global display, typography, and link styles. Specifically, we:
-background-color: #fff;
on the body
@font-family-base
, @font-size-base
, and @line-height-base
attributes as our typographic base@link-color
and apply link underlines only on :hover
These styles can be found within scaffolding.less
.
For improved cross-browser rendering, we use Normalize.css, a project by Nicolas Gallagher and Jonathan Neal.
- -Bootstrap requires a containing element to wrap site contents and house our grid system. You may choose one of two containers to use in your projects. Note that, due to padding
and more, neither container is nestable.
Use .container
for a responsive fixed width container.
Use .container-fluid
for a full width container, spanning the entire width of your viewport.
Bootstrap includes a responsive, mobile first fluid grid system that appropriately scales up to 12 columns as the device or viewport size increases. It includes predefined classes for easy layout options, as well as powerful mixins for generating more semantic layouts.
- -Grid systems are used for creating page layouts through a series of rows and columns that house your content. Here's how the Bootstrap grid system works:
-.container
(fixed-width) or .container-fluid
(full-width) for proper alignment and padding..row
and .col-xs-4
are available for quickly making grid layouts. Less mixins can also be used for more semantic layouts.padding
. That padding is offset in rows for the first and last column via negative margin on .row
s..col-xs-4
..col-md-
class to an element will not only affect its styling on medium devices but also on large devices if a .col-lg-
class is not present.Look to the examples for applying these principles to your code.
- -We use the following media queries in our Less files to create the key breakpoints in our grid system.
-{% highlight scss %} -/* Extra small devices (phones, less than 768px) */ -/* No media query since this is the default in Bootstrap */ - -/* Small devices (tablets, 768px and up) */ -@media (min-width: @screen-sm-min) { ... } - -/* Medium devices (desktops, 992px and up) */ -@media (min-width: @screen-md-min) { ... } - -/* Large devices (large desktops, 1200px and up) */ -@media (min-width: @screen-lg-min) { ... } -{% endhighlight %} -We occasionally expand on these media queries to include a max-width
to limit CSS to a narrower set of devices.
See how aspects of the Bootstrap grid system work across multiple devices with a handy table.
-- | - Extra small devices - Phones (<768px) - | -- Small devices - Tablets (≥768px) - | -- Medium devices - Desktops (≥992px) - | -- Large devices - Desktops (≥1200px) - | -
---|---|---|---|---|
Grid behavior | -Horizontal at all times | -Collapsed to start, horizontal above breakpoints | -||
Container width | -None (auto) | -750px | -970px | -1170px | -
Class prefix | -.col-xs- |
- .col-sm- |
- .col-md- |
- .col-lg- |
-
# of columns | -12 | -|||
Column width | -Auto | -~62px | -~81px | -~97px | -
Gutter width | -30px (15px on each side of a column) | -|||
Nestable | -Yes | -|||
Offsets | -Yes | -|||
Column ordering | -Yes | -
Using a single set of .col-md-*
grid classes, you can create a basic grid system that starts out stacked on mobile devices and tablet devices (the extra small to small range) before becoming horizontal on desktop (medium) devices. Place grid columns in any .row
.
Turn any fixed-width grid layout into a full-width layout by changing your outermost .container
to .container-fluid
.
Don't want your columns to simply stack in smaller devices? Use the extra small and medium device grid classes by adding .col-xs-*
.col-md-*
to your columns. See the example below for a better idea of how it all works.
Build on the previous example by creating even more dynamic and powerful layouts with tablet .col-sm-*
classes.
With the four tiers of grids available you're bound to run into issues where, at certain breakpoints, your columns don't clear quite right as one is taller than the other. To fix that, use a combination of a .clearfix
and our responsive utility classes.
In addition to column clearing at responsive breakpoints, you may need to reset offsets, pushes, or pulls. See this in action in the grid example.
-{% highlight html %} -Move columns to the right using .col-md-offset-*
classes. These classes increase the left margin of a column by *
columns. For example, .col-md-offset-4
moves .col-md-4
over four columns.
To nest your content with the default grid, add a new .row
and set of .col-md-*
columns within an existing .col-md-*
column. Nested rows should include a set of columns that add up to 12 or less.
Easily change the order of our built-in grid columns with .col-md-push-*
and .col-md-pull-*
modifier classes.
In addition to prebuilt grid classes for fast layouts, Bootstrap includes Less variables and mixins for quickly generating your own simple, semantic layouts.
- -Variables determine the number of columns, the gutter width, and the media query point at which to begin floating columns. We use these to generate the predefined grid classes documented above, as well as for the custom mixins listed below.
-{% highlight scss %} -@grid-columns: 12; -@grid-gutter-width: 30px; -@grid-float-breakpoint: 768px; -{% endhighlight %} - -Mixins are used in conjunction with the grid variables to generate semantic CSS for individual grid columns.
-{% highlight scss %} -// Creates a wrapper for a series of columns -.make-row(@gutter: @grid-gutter-width) { - // Then clear the floated columns - .clearfix(); - - @media (min-width: @screen-sm-min) { - margin-left: (@gutter / -2); - margin-right: (@gutter / -2); - } - - // Negative margin nested rows out to align the content of columns - .row { - margin-left: (@gutter / -2); - margin-right: (@gutter / -2); - } -} - -// Generate the extra small columns -.make-xs-column(@columns; @gutter: @grid-gutter-width) { - position: relative; - // Prevent columns from collapsing when empty - min-height: 1px; - // Inner gutter via padding - padding-left: (@gutter / 2); - padding-right: (@gutter / 2); - - // Calculate width based on number of columns available - @media (min-width: @grid-float-breakpoint) { - float: left; - width: percentage((@columns / @grid-columns)); - } -} - -// Generate the small columns -.make-sm-column(@columns; @gutter: @grid-gutter-width) { - position: relative; - // Prevent columns from collapsing when empty - min-height: 1px; - // Inner gutter via padding - padding-left: (@gutter / 2); - padding-right: (@gutter / 2); - - // Calculate width based on number of columns available - @media (min-width: @screen-sm-min) { - float: left; - width: percentage((@columns / @grid-columns)); - } -} - -// Generate the small column offsets -.make-sm-column-offset(@columns) { - @media (min-width: @screen-sm-min) { - margin-left: percentage((@columns / @grid-columns)); - } -} -.make-sm-column-push(@columns) { - @media (min-width: @screen-sm-min) { - left: percentage((@columns / @grid-columns)); - } -} -.make-sm-column-pull(@columns) { - @media (min-width: @screen-sm-min) { - right: percentage((@columns / @grid-columns)); - } -} - -// Generate the medium columns -.make-md-column(@columns; @gutter: @grid-gutter-width) { - position: relative; - // Prevent columns from collapsing when empty - min-height: 1px; - // Inner gutter via padding - padding-left: (@gutter / 2); - padding-right: (@gutter / 2); - - // Calculate width based on number of columns available - @media (min-width: @screen-md-min) { - float: left; - width: percentage((@columns / @grid-columns)); - } -} - -// Generate the medium column offsets -.make-md-column-offset(@columns) { - @media (min-width: @screen-md-min) { - margin-left: percentage((@columns / @grid-columns)); - } -} -.make-md-column-push(@columns) { - @media (min-width: @screen-md-min) { - left: percentage((@columns / @grid-columns)); - } -} -.make-md-column-pull(@columns) { - @media (min-width: @screen-md-min) { - right: percentage((@columns / @grid-columns)); - } -} - -// Generate the large columns -.make-lg-column(@columns; @gutter: @grid-gutter-width) { - position: relative; - // Prevent columns from collapsing when empty - min-height: 1px; - // Inner gutter via padding - padding-left: (@gutter / 2); - padding-right: (@gutter / 2); - - // Calculate width based on number of columns available - @media (min-width: @screen-lg-min) { - float: left; - width: percentage((@columns / @grid-columns)); - } -} - -// Generate the large column offsets -.make-lg-column-offset(@columns) { - @media (min-width: @screen-lg-min) { - margin-left: percentage((@columns / @grid-columns)); - } -} -.make-lg-column-push(@columns) { - @media (min-width: @screen-lg-min) { - left: percentage((@columns / @grid-columns)); - } -} -.make-lg-column-pull(@columns) { - @media (min-width: @screen-lg-min) { - right: percentage((@columns / @grid-columns)); - } -} -{% endhighlight %} - -You can modify the variables to your own custom values, or just use the mixins with their default values. Here's an example of using the default settings to create a two-column layout with a gap between.
-{% highlight scss %} -.wrapper { - .make-row(); -} -.content-main { - .make-lg-column(8); -} -.content-secondary { - .make-lg-column(3); - .make-lg-column-offset(1); -} -{% endhighlight %} -{% highlight html %} -All HTML headings, <h1>
through <h6>
, are available. .h1
through .h6
classes are also available, for when you want to match the font styling of a heading but still want your text to be displayed inline.
h1. Bootstrap heading |
- Semibold 36px | -
h2. Bootstrap heading |
- Semibold 30px | -
h3. Bootstrap heading |
- Semibold 24px | -
h4. Bootstrap heading |
- Semibold 18px | -
h5. Bootstrap heading |
- Semibold 14px | -
h6. Bootstrap heading |
- Semibold 12px | -
Create lighter, secondary text in any heading with a generic <small>
tag or the .small
class.
h1. Bootstrap heading Secondary text |
-
h2. Bootstrap heading Secondary text |
-
h3. Bootstrap heading Secondary text |
-
h4. Bootstrap heading Secondary text |
-
h5. Bootstrap heading Secondary text |
-
h6. Bootstrap heading Secondary text |
-
Bootstrap's global default font-size
is 14px, with a line-height
of 1.428. This is applied to the <body>
and all paragraphs. In addition, <p>
(paragraphs) receive a bottom margin of half their computed line-height (10px by default).
Nullam quis risus eget urna mollis ornare vel eu leo. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nullam id dolor id nibh ultricies vehicula.
-Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec ullamcorper nulla non metus auctor fringilla. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit. Donec ullamcorper nulla non metus auctor fringilla.
-Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit.
-...
-{% endhighlight %} - - -Make a paragraph stand out by adding .lead
.
Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor. Duis mollis, est non commodo luctus.
-...
-{% endhighlight %} - - -The typographic scale is based on two Less variables in variables.less: @font-size-base
and @line-height-base
. The first is the base font-size used throughout and the second is the base line-height. We use those variables and some simple math to create the margins, paddings, and line-heights of all our type and more. Customize them and Bootstrap adapts.
For indicating blocks of text that have been deleted use the <mark>
tag.
You can use the mark tag to highlight text.
-For indicating blocks of text that have been deleted use the <del>
tag.
This line of text is meant to be treated as deleted text.
For indicating blocks of text that are no longer relevant use the <s>
tag.
This line of text is meant to be treated as no longer accurate.
For indicating additions to the document use the <ins>
tag.
This line of text is meant to be treated as an addition to the document.
-To underline text use the <u>
tag.
This line of text is will render as underlined
-Make use of HTML's default emphasis tags with lightweight styles.
- -For de-emphasizing inline or blocks of text, use the <small>
tag to set text at 85% the size of the parent. Heading elements receive their own font-size
for nested <small>
elements.
You may alternatively use an inline element with .small
in place of any <small>
.
This line of text is meant to be treated as fine print.
-For emphasizing a snippet of text with a heavier font-weight.
-The following snippet of text is rendered as bold text.
-For emphasizing a snippet of text with italics.
-The following snippet of text is rendered as italicized text.
-Feel free to use <b>
and <i>
in HTML5. <b>
is meant to highlight words or phrases without conveying additional importance while <i>
is mostly for voice, technical terms, etc.
Easily realign text to components with text alignment classes.
-Left aligned text.
-Center aligned text.
-Right aligned text.
-Justified text.
-Left aligned text.
-Center aligned text.
-Right aligned text.
-Justified text.
-{% endhighlight %} - - - -Stylized implementation of HTML's <abbr>
element for abbreviations and acronyms to show the expanded version on hover. Abbreviations with a title
attribute have a light dotted bottom border and a help cursor on hover, providing additional context on hover.
For expanded text on long hover of an abbreviation, include the title
attribute with the <abbr>
element.
An abbreviation of the word attribute is attr.
-Add .initialism
to an abbreviation for a slightly smaller font-size.
HTML is the best thing since sliced bread.
-Present contact information for the nearest ancestor or the entire body of work. Preserve formatting by ending all lines with <br>
.
For quoting blocks of content from another source within your document.
- -Wrap <blockquote>
around any HTML as the quote. For straight quotes, we recommend a <p>
.
--Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat a ante.
-
--{% endhighlight %} - -Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat a ante.
-
Style and content changes for simple variations on a standard <blockquote>
.
Add a <footer>
for identifying the source. Wrap the name of the source work in <cite>
.
--Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat a ante.
- -
--{% endhighlight %} - -Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat a ante.
- -
Add .blockquote-reverse
for a blockquote with right-aligned content.
- ... --{% endhighlight %} - - - -
A list of items in which the order does not explicitly matter.
-A list of items in which the order does explicitly matter.
-Remove the default list-style
and left margin on list items (immediate children only). This only applies to immediate children list items, meaning you will need to add the class for any nested lists as well.
Place all list items on a single line with display: inline-block;
and some light padding.
A list of terms with their associated descriptions.
-Make terms and descriptions in <dl>
line up side-by-side. Starts off stacked like default <dl>
s, but when the navbar expands, so do these.
Horizontal description lists will truncate terms that are too long to fit in the left column with text-overflow
. In narrower viewports, they will change to the default stacked layout.
Wrap inline snippets of code with <code>
.
<section>
should be wrapped as inline.
-<section>
should be wrapped as inline.
-{% endhighlight %}
-
- Use the <kbd>
to indicate input that is typically entered via keyboard.
Use <pre>
for multiple lines of code. Be sure to escape any angle brackets in the code for proper rendering.
<p>Sample text here...</p>-
<p>Sample text here...</p>-{% endhighlight %} - -
You may optionally add the .pre-scrollable
class, which will set a max-height of 350px and provide a y-axis scrollbar.
For indicating variables use the <var>
tag.
y = mx + b
- -For indicating blocks sample output from a program use the <samp>
tag.
This text is meant to be treated as sample output from a computer program.
-For basic styling—light padding and only horizontal dividers—add the base class .table
to any <table>
. It may seem super redundant, but given the widespread use of tables for other plugins like calendars and date pickers, we've opted to isolate our custom table styles.
# | -First Name | -Last Name | -Username | -
---|---|---|---|
1 | -Mark | -Otto | -@mdo | -
2 | -Jacob | -Thornton | -@fat | -
3 | -Larry | -the Bird | -
Use .table-striped
to add zebra-striping to any table row within the <tbody>
.
Striped tables are styled via the :nth-child
CSS selector, which is not available in Internet Explorer 8.
# | -First Name | -Last Name | -Username | -
---|---|---|---|
1 | -Mark | -Otto | -@mdo | -
2 | -Jacob | -Thornton | -@fat | -
3 | -Larry | -the Bird | -
Add .table-bordered
for borders on all sides of the table and cells.
# | -First Name | -Last Name | -Username | -
---|---|---|---|
1 | -Mark | -Otto | -@mdo | -
Mark | -Otto | -@TwBootstrap | -|
2 | -Jacob | -Thornton | -@fat | -
3 | -Larry the Bird | -
Add .table-hover
to enable a hover state on table rows within a <tbody>
.
# | -First Name | -Last Name | -Username | -
---|---|---|---|
1 | -Mark | -Otto | -@mdo | -
2 | -Jacob | -Thornton | -@fat | -
3 | -Larry the Bird | -
Add .table-condensed
to make tables more compact by cutting cell padding in half.
# | -First Name | -Last Name | -Username | -
---|---|---|---|
1 | -Mark | -Otto | -@mdo | -
2 | -Jacob | -Thornton | -@fat | -
3 | -Larry the Bird | -
Use contextual classes to color table rows or individual cells.
-Class | -Description | -
---|---|
- .active
- |
- Applies the hover color to a particular row or cell | -
- .success
- |
- Indicates a successful or positive action | -
- .info
- |
- Indicates a neutral informative change or action | -
- .warning
- |
- Indicates a warning that might need attention | -
- .danger
- |
- Indicates a dangerous or potentially negative action | -
# | -Column heading | -Column heading | -Column heading | -
---|---|---|---|
1 | -Column content | -Column content | -Column content | -
2 | -Column content | -Column content | -Column content | -
3 | -Column content | -Column content | -Column content | -
4 | -Column content | -Column content | -Column content | -
5 | -Column content | -Column content | -Column content | -
6 | -Column content | -Column content | -Column content | -
7 | -Column content | -Column content | -Column content | -
8 | -Column content | -Column content | -Column content | -
9 | -Column content | -Column content | -Column content | -
Create responsive tables by wrapping any .table
in .table-responsive
to make them scroll horizontally up to small devices (under 768px). When viewing on anything larger than 768px wide, you will not see any difference in these tables.
# | -Table heading | -Table heading | -Table heading | -Table heading | -Table heading | -Table heading | -
---|---|---|---|---|---|---|
1 | -Table cell | -Table cell | -Table cell | -Table cell | -Table cell | -Table cell | -
2 | -Table cell | -Table cell | -Table cell | -Table cell | -Table cell | -Table cell | -
3 | -Table cell | -Table cell | -Table cell | -Table cell | -Table cell | -Table cell | -
# | -Table heading | -Table heading | -Table heading | -Table heading | -Table heading | -Table heading | -
---|---|---|---|---|---|---|
1 | -Table cell | -Table cell | -Table cell | -Table cell | -Table cell | -Table cell | -
2 | -Table cell | -Table cell | -Table cell | -Table cell | -Table cell | -Table cell | -
3 | -Table cell | -Table cell | -Table cell | -Table cell | -Table cell | -Table cell | -
Individual form controls automatically receive some global styling. All textual <input>
, <textarea>
, and <select>
elements with .form-control
are set to width: 100%;
by default. Wrap labels and controls in .form-group
for optimum spacing.
Do not mix form groups directly with input groups. Instead, nest the input group inside of the form group.
-Add .form-inline
to your <form>
for left-aligned and inline-block controls. This only applies to forms within viewports that are at least 768px wide.
Inputs, selects, and textareas are 100% wide by default in Bootstrap. To use the inline form, you'll have to set a width on the form controls used within.
-Screen readers will have trouble with your forms if you don't include a label for every input. For these inline forms, you can hide the labels using the .sr-only
class.
Use Bootstrap's predefined grid classes to align labels and groups of form controls in a horizontal layout by adding .form-horizontal
to the form. Doing so changes .form-group
s to behave as grid rows, so no need for .row
.
Examples of standard form controls supported in an example form layout.
- -Most common form control, text-based input fields. Includes support for all HTML5 types: text
, password
, datetime
, datetime-local
, date
, month
, time
, week
, number
, email
, url
, search
, tel
, and color
.
Inputs will only be fully styled if their type
is properly declared.
To add integrated text or buttons before and/or after any text-based <input>
, check out the input group component.
Form control which supports multiple lines of text. Change rows
attribute as necessary.
Checkboxes are for selecting one or several options in a list while radios are for selecting one option from many.
-Use the .checkbox-inline
or .radio-inline
classes on a series of checkboxes or radios for controls that appear on the same line.
Use the default option, or add multiple
to show multiple options at once.
When you need to place plain text next to a form label within a horizontal form, use the .form-control-static
class on a <p>
.
We remove the default outline
styles on some form controls and apply a box-shadow
in its place for :focus
.
:focus
stateThe above example input uses custom styles in our documentation to demonstrate the :focus
state on a .form-control
.
Add the disabled
boolean attribute on an input to prevent user input and trigger a slightly different look.
Add the disabled
attribute to a <fieldset>
to disable all the controls within the <fieldset>
at once.
<a>
Our styles use pointer-events: none
to try to disable the link functionality of <a class="btn btn-*">
buttons in this case, but that CSS property is not yet standardized and isn't fully supported in Opera 18 and below, or in Internet Explorer 11. So to be safe, use custom JavaScript to disable such links.
While Bootstrap will apply these styles in all browsers, Internet Explorer 9 and below don't actually support the disabled
attribute on a <fieldset>
. Use custom JavaScript to disable the fieldset in these browsers.
Add the readonly
boolean attribute on an input to prevent user input and style the input as disabled.
Bootstrap includes validation styles for error, warning, and success states on form controls. To use, add .has-warning
, .has-error
, or .has-success
to the parent element. Any .control-label
, .form-control
, and .help-block
within that element will receive the validation styles.
You can also add optional feedback icons with the addition of .has-feedback
and the right icon.
Manual positioning of feedback icons is required for inputs without a label and for input groups with an add-on on the right. For inputs without labels, adjust the top
value. For input groups, adjust the right
value to an appropriate pixel value depending on the width of your addon.
Optional icons also work on horizontal and inline forms.
-Set heights using classes like .input-lg
, and set widths using grid column classes like .col-lg-*
.
Create taller or shorter form controls that match button sizes.
-Wrap inputs in grid columns, or any custom parent element, to easily enforce desired widths.
-Block level help text for form controls.
-Use any of the available button classes to quickly create a styled button.
-Fancy larger or smaller buttons? Add .btn-lg
, .btn-sm
, or .btn-xs
for additional sizes.
- - -
-- - -
-- - -
-- - -
-- - -
-- - -
-- - -
-- - -
-{% endhighlight %} - -Create block level buttons—those that span the full width of a parent— by adding .btn-block
.
Buttons will appear pressed (with a darker background, darker border, and inset shadow) when active. For <button>
elements, this is done via :active
. For <a>
elements, it's done with .active
. However, you may use .active
on <button>
s should you need to replicate the active state progammatically.
No need to add :active
as it's a pseudo-class, but if you need to force the same appearance, go ahead and add .active
.
- - -
-{% highlight html %} - - -{% endhighlight %} - -Add the .active
class to <a>
buttons.
- Primary link - Link -
-{% highlight html %} -Primary link -Link -{% endhighlight %} - - -Make buttons look unclickable by fading them back 50%.
- -Add the disabled
attribute to <button>
buttons.
- - -
-{% highlight html %} - - -{% endhighlight %} - -If you add the disabled
attribute to a <button>
, Internet Explorer 9 and below will render text gray with a nasty text-shadow that we cannot fix.
Add the .disabled
class to <a>
buttons.
- Primary link - Link -
-{% highlight html %} -Primary link -Link -{% endhighlight %} -
- We use .disabled
as a utility class here, similar to the common .active
class, so no prefix is required.
-
This class uses pointer-events: none
to try to disable the link functionality of <a>
s, but that CSS property is not yet standardized and isn't fully supported in Opera 18 and below, or in Internet Explorer 11. So to be safe, use custom JavaScript to disable such links.
While button classes can be used on <a>
and <button>
elements, only <button>
elements are supported within our nav and navbar components.
Use the button classes on an <a>
, <button>
, or <input>
element.
As a best practice, we highly recommend using the <button>
element whenever possible to ensure matching cross-browser rendering.
Among other things, there's a Firefox bug that prevents us from setting the line-height
of <input>
-based buttons, causing them to not exactly match the height of other buttons on Firefox.
Images in Bootstrap 3 can be made responsive-friendly via the addition of the .img-responsive
class. This applies max-width: 100%;
and height: auto;
to the image so that it scales nicely to the parent element.
Add classes to an <img>
element to easily style images in any project.
Keep in mind that Internet Explorer 8 lacks support for rounded corners.
-Convey meaning through color with a handful of emphasis utility classes. These may also be applied to links and will darken on hover just like our default link styles.
-Fusce dapibus, tellus ac cursus commodo, tortor mauris nibh.
-Nullam id dolor id nibh ultricies vehicula ut id elit.
-Duis mollis, est non commodo luctus, nisi erat porttitor ligula.
-Maecenas sed diam eget risus varius blandit sit amet non magna.
-Etiam porta sem malesuada magna mollis euismod.
-Donec ullamcorper nulla non metus auctor fringilla.
-...
-...
-...
-...
-...
-...
-{% endhighlight %} -Sometimes emphasis classes cannot be applied due to the specificity of another selector. In most cases, a sufficient workaround is to wrap your text in a <span>
with the class.
Similar to the contextual text color classes, easily set the background of an element to any contextual class. Anchor components will darken on hover, just like the text classes.
-Nullam id dolor id nibh ultricies vehicula ut id elit.
-Duis mollis, est non commodo luctus, nisi erat porttitor ligula.
-Maecenas sed diam eget risus varius blandit sit amet non magna.
-Etiam porta sem malesuada magna mollis euismod.
-Donec ullamcorper nulla non metus auctor fringilla.
-...
-...
-...
-...
-...
-{% endhighlight %} - - -Use the generic close icon for dismissing content like modals and alerts.
-Use carets to indicate dropdown functionality and direction. Note that the default caret will reverse automatically in dropup menus.
-Float an element to the left or right with a class. !important
is included to avoid specificity issues. Classes can also be used as mixins.
To align components in navbars with utility classes, use .navbar-left
or .navbar-right
instead. See the navbar docs for details.
Set an element to display: block
and center via margin
. Available as a mixin and class.
Clear the float
on any element with the .clearfix
class. Utilizes the micro clearfix as popularized by Nicolas Gallagher. Can also be used as a mixin.
Force an element to be shown or hidden (including for screen readers) with the use of .show
and .hidden
classes. These classes use !important
to avoid specificity conflicts, just like the quick floats. They are only available for block level toggling. They can also be used as mixins.
.hide
is available, but it does not always affect screen readers and is deprecated as of v3.0.1. Use .hidden
or .sr-only
instead.
Furthermore, .invisible
can be used to toggle only the visibility of an element, meaning its display
is not modified and the element can still affect the flow of the document.
Hide an element to all devices except screen readers with .sr-only
. Combine .sr-only
with .sr-only-focusable
to show the element again when it's focused (e.g. by a keyboard-only user). Necessary for following accessibility best practices. Can also be used as mixins.
Utilize the .text-hide
class or mixin to help replace an element's text content with a background image.
For faster mobile-friendly development, use these utility classes for showing and hiding content by device via media query. Also included are utility classes for toggling content when printed.
-Try to use these on a limited basis and avoid creating entirely different versions of the same site. Instead, use them to complement each device's presentation.
- - -Use a single or combination of the available classes for toggling content across viewport breakpoints.
-- | - Extra small devices - Phones (<768px) - | -- Small devices - Tablets (≥768px) - | -- Medium devices - Desktops (≥992px) - | -- Large devices - Desktops (≥1200px) - | -
---|---|---|---|---|
.visible-xs-* |
- Visible | -Hidden | -Hidden | -Hidden | -
.visible-sm-* |
- Hidden | -Visible | -Hidden | -Hidden | -
.visible-md-* |
- Hidden | -Hidden | -Visible | -Hidden | -
.visible-lg-* |
- Hidden | -Hidden | -Hidden | -Visible | -
.hidden-xs |
- Hidden | -Visible | -Visible | -Visible | -
.hidden-sm |
- Visible | -Hidden | -Visible | -Visible | -
.hidden-md |
- Visible | -Visible | -Hidden | -Visible | -
.hidden-lg |
- Visible | -Visible | -Visible | -Hidden | -
As of v3.2, the .visible-*-*
classes for each breakpoint come in three variations, one for each CSS display
property value listed below.
Group of classes | -CSS display |
-
---|---|
.visible-*-block |
- display: block; |
-
.visible-*-inline |
- display: inline; |
-
.visible-*-inline-block |
- display: inline-block; |
-
So, for extra small (xs
) screens for example, the available .visible-*-*
classes are: .visible-xs-block
, .visible-xs-inline
, and .visible-xs-inline-block
.
The classes .visible-xs
, .visible-sm
, .visible-md
, and .visible-lg
also exist, but are deprecated as of v3.2. They are approximately equivalent to .visible-*-block
, except with additional special cases for toggling <table>
-related elements.
Similar to the regular responsive classes, use these for toggling content for print.
-Classes | -Browser | -|
---|---|---|
- .visible-print-block - .visible-print-inline - .visible-print-inline-block
- |
- Hidden | -Visible | -
.hidden-print |
- Visible | -Hidden | -
The class .visible-print
also exists but is deprecated as of v3.1.0. It is approximately equivalent to .visible-print-block
, except with additional special cases for <table>
-related elements.
Resize your browser or load on different devices to test the responsive utility classes.
- -Green checkmarks indicate the element is visible in your current viewport.
-Here, green checkmarks also indicate the element is hidden in your current viewport.
- - -Bootstrap's CSS is built on Less, a preprocessor with additional functionality like variables, mixins, and functions for compiling CSS. Those looking to use the source Less files instead of our compiled CSS files can make use of the numerous variables and mixins we use throughout the framework.
- -Grid variables and mixins are covered within the Grid system section.
- - -Bootstrap can be used in at least two ways: with the compiled CSS or with the source Less files. To compile the Less files, visit the README for how to setup your development environment to run the necessary commands.
-Third party compilation tools may work with Bootstrap, but they are not supported by our core team.
- -Variables are used throughout the entire project as a way to centralize and share commonly used values like colors, spacing, or font stacks. For a complete breakdown, please see the Customizer.
- -Easily make use of two color schemes: grayscale and semantic. Grayscale colors provide quick access to commonly used shades of black while semantic include various colors assigned to meaningful contextual values.
-Use any of these color variables as they are or reassign them to more meaningful variables for your project.
-{% highlight scss %} -// Use as-is -.masthead { - background-color: @brand-primary; -} - -// Reassigned variables in Less -@alert-message-background: @brand-info; -.alert { - background-color: @alert-message-background; -} -{% endhighlight %} - -A handful of variables for quickly customizing key elements of your site's skeleton.
-{% highlight scss %} -// Scaffolding -@body-bg: #fff; -@text-color: @black-50; -{% endhighlight %} - -Easily style your links with the right color with only one value.
-{% highlight scss %} -// Variables -@link-color: @brand-primary; -@link-color-hover: darken(@link-color, 15%); - -// Usage -a { - color: @link-color; - text-decoration: none; - - &:hover { - color: @link-color-hover; - text-decoration: underline; - } -} -{% endhighlight %} -Note that the @link-color-hover
uses a function, another awesome tool from Less, to automagically create the right hover color. You can use darken
, lighten
, saturate
, and desaturate
.
Easily set your type face, text size, leading, and more with a few quick variables. Bootstrap makes use of these as well to provide easy typographic mixins.
-{% highlight scss %} -@font-family-sans-serif: "Helvetica Neue", Helvetica, Arial, sans-serif; -@font-family-serif: Georgia, "Times New Roman", Times, serif; -@font-family-monospace: Menlo, Monaco, Consolas, "Courier New", monospace; -@font-family-base: @font-family-sans-serif; - -@font-size-base: 14px; -@font-size-large: ceil((@font-size-base * 1.25)); // ~18px -@font-size-small: ceil((@font-size-base * 0.85)); // ~12px - -@font-size-h1: floor((@font-size-base * 2.6)); // ~36px -@font-size-h2: floor((@font-size-base * 2.15)); // ~30px -@font-size-h3: ceil((@font-size-base * 1.7)); // ~24px -@font-size-h4: ceil((@font-size-base * 1.25)); // ~18px -@font-size-h5: @font-size-base; -@font-size-h6: ceil((@font-size-base * 0.85)); // ~12px - -@line-height-base: 1.428571429; // 20/14 -@line-height-computed: floor((@font-size-base * @line-height-base)); // ~20px - -@headings-font-family: inherit; -@headings-font-weight: 500; -@headings-line-height: 1.1; -@headings-color: inherit; -{% endhighlight %} - -Two quick variables for customizing the location and filename of your icons.
-{% highlight scss %} -@icon-font-path: "../fonts/"; -@icon-font-name: "glyphicons-halflings-regular"; -{% endhighlight %} - -Components throughout Bootstrap make use of some default variables for setting common values. Here are the most commonly used.
-{% highlight scss %} -@padding-base-vertical: 6px; -@padding-base-horizontal: 12px; - -@padding-large-vertical: 10px; -@padding-large-horizontal: 16px; - -@padding-small-vertical: 5px; -@padding-small-horizontal: 10px; - -@padding-xs-vertical: 1px; -@padding-xs-horizontal: 5px; - -@line-height-large: 1.33; -@line-height-small: 1.5; - -@border-radius-base: 4px; -@border-radius-large: 6px; -@border-radius-small: 3px; - -@component-active-color: #fff; -@component-active-bg: @brand-primary; - -@caret-width-base: 4px; -@caret-width-large: 5px; -{% endhighlight %} - - -Vendor mixins are mixins to help support multiple browsers by including all relevant vendor prefixes in your compiled CSS.
- - -Reset your components' box model with a single mixin. For context, see this helpful article from Mozilla.
-The mixin is deprecated as of v3.2.0, with the introduction of autoprefixer. To preserve backwards-compatibility, Bootstrap will continue to use the mixin internally until Bootstrap v4.
-{% highlight scss %} -.box-sizing(@box-model) { - -webkit-box-sizing: @box-model; // Safari <= 5 - -moz-box-sizing: @box-model; // Firefox <= 19 - box-sizing: @box-model; -} -{% endhighlight %} - -Today all modern browsers support the non-prefixed border-radius
property. As such, there is no .border-radius()
mixin, but Bootstrap does include shortcuts for quickly rounding two corners on a particular side of an object.
If your target audience is using the latest and greatest browsers and devices, be sure to just use the box-shadow
property on its own. If you need support for older Android (pre-v4) and iOS devices (pre-iOS 5), use the deprecated mixin to pick up the required -webkit
prefix.
The mixin is deprecated as of v3.1.0, since Bootstrap doesn't officially support the outdated platforms that don't support the standard property. To preserve backwards-compatibility, Bootstrap will continue to use the mixin internally until Bootstrap v4.
-Be sure to use rgba()
colors in your box shadows so they blend as seamlessly as possible with backgrounds.
Multiple mixins for flexibility. Set all transition information with one, or specify a separate delay and duration as needed.
-The mixins are deprecated as of v3.2.0, with the introduction of autoprefixer. To preserve backwards-compatibility, Bootstrap will continue to use the mixins internally until Bootstrap v4.
-{% highlight scss %} -.transition(@transition) { - -webkit-transition: @transition; - transition: @transition; -} -.transition-property(@transition-property) { - -webkit-transition-property: @transition-property; - transition-property: @transition-property; -} -.transition-delay(@transition-delay) { - -webkit-transition-delay: @transition-delay; - transition-delay: @transition-delay; -} -.transition-duration(@transition-duration) { - -webkit-transition-duration: @transition-duration; - transition-duration: @transition-duration; -} -.transition-timing-function(@timing-function) { - -webkit-transition-timing-function: @timing-function; - transition-timing-function: @timing-function; -} -.transition-transform(@transition) { - -webkit-transition: -webkit-transform @transition; - -moz-transition: -moz-transform @transition; - -o-transition: -o-transform @transition; - transition: transform @transition; -} -{% endhighlight %} - -Rotate, scale, translate (move), or skew any object.
-The mixins are deprecated as of v3.2.0, with the introduction of autoprefixer. To preserve backwards-compatibility, Bootstrap will continue to use the mixins internally until Bootstrap v4.
-{% highlight scss %} -.rotate(@degrees) { - -webkit-transform: rotate(@degrees); - -ms-transform: rotate(@degrees); // IE9 only - transform: rotate(@degrees); -} -.scale(@ratio; @ratio-y...) { - -webkit-transform: scale(@ratio, @ratio-y); - -ms-transform: scale(@ratio, @ratio-y); // IE9 only - transform: scale(@ratio, @ratio-y); -} -.translate(@x; @y) { - -webkit-transform: translate(@x, @y); - -ms-transform: translate(@x, @y); // IE9 only - transform: translate(@x, @y); -} -.skew(@x; @y) { - -webkit-transform: skew(@x, @y); - -ms-transform: skewX(@x) skewY(@y); // See https://github.com/twbs/bootstrap/issues/4885; IE9+ - transform: skew(@x, @y); -} -.translate3d(@x; @y; @z) { - -webkit-transform: translate3d(@x, @y, @z); - transform: translate3d(@x, @y, @z); -} - -.rotateX(@degrees) { - -webkit-transform: rotateX(@degrees); - -ms-transform: rotateX(@degrees); // IE9 only - transform: rotateX(@degrees); -} -.rotateY(@degrees) { - -webkit-transform: rotateY(@degrees); - -ms-transform: rotateY(@degrees); // IE9 only - transform: rotateY(@degrees); -} -.perspective(@perspective) { - -webkit-perspective: @perspective; - -moz-perspective: @perspective; - perspective: @perspective; -} -.perspective-origin(@perspective) { - -webkit-perspective-origin: @perspective; - -moz-perspective-origin: @perspective; - perspective-origin: @perspective; -} -.transform-origin(@origin) { - -webkit-transform-origin: @origin; - -moz-transform-origin: @origin; - -ms-transform-origin: @origin; // IE9 only - transform-origin: @origin; -} -{% endhighlight %} - -A single mixin for using all of CSS3's animation properties in one declaration and other mixins for individual properties.
-The mixins are deprecated as of v3.2.0, with the introduction of autoprefixer. To preserve backwards-compatibility, Bootstrap will continue to use the mixins internally until Bootstrap v4.
-{% highlight scss %} -.animation(@animation) { - -webkit-animation: @animation; - animation: @animation; -} -.animation-name(@name) { - -webkit-animation-name: @name; - animation-name: @name; -} -.animation-duration(@duration) { - -webkit-animation-duration: @duration; - animation-duration: @duration; -} -.animation-timing-function(@timing-function) { - -webkit-animation-timing-function: @timing-function; - animation-timing-function: @timing-function; -} -.animation-delay(@delay) { - -webkit-animation-delay: @delay; - animation-delay: @delay; -} -.animation-iteration-count(@iteration-count) { - -webkit-animation-iteration-count: @iteration-count; - animation-iteration-count: @iteration-count; -} -.animation-direction(@direction) { - -webkit-animation-direction: @direction; - animation-direction: @direction; -} -{% endhighlight %} - -Set the opacity for all browsers and provide a filter
fallback for IE8.
Provide context for form controls within each field.
-{% highlight scss %} -.placeholder(@color: @input-color-placeholder) { - &::-moz-placeholder { color: @color; } // Firefox - &:-ms-input-placeholder { color: @color; } // Internet Explorer 10+ - &::-webkit-input-placeholder { color: @color; } // Safari and Chrome -} -{% endhighlight %} - -Generate columns via CSS within a single element.
-{% highlight scss %} -.content-columns(@width; @count; @gap) { - -webkit-column-width: @width; - -moz-column-width: @width; - column-width: @width; - -webkit-column-count: @count; - -moz-column-count: @count; - column-count: @count; - -webkit-column-gap: @gap; - -moz-column-gap: @gap; - column-gap: @gap; -} -{% endhighlight %} - -Easily turn any two colors into a background gradient. Get more advanced and set a direction, use three colors, or use a radial gradient. With a single mixin you get all the prefixed syntaxes you'll need.
-{% highlight scss %} -#gradient > .vertical(#333; #000); -#gradient > .horizontal(#333; #000); -#gradient > .radial(#333; #000); -{% endhighlight %} -You can also specify the angle of a standard two-color, linear gradient:
-{% highlight scss %} -#gradient > .directional(#333; #000; 45deg); -{% endhighlight %} -If you need a barber-stripe style gradient, that's easy, too. Just specify a single color and we'll overlay a translucent white stripe.
-{% highlight scss %} -#gradient > .striped(#333; 45deg); -{% endhighlight %} -Up the ante and use three colors instead. Set the first color, the second color, the second color's color stop (a decimal value like 0.25), and the third color with these mixins:
-{% highlight scss %} -#gradient > .vertical-three-colors(#777; #333; .25; #000); -#gradient > .horizontal-three-colors(#777; #333; .25; #000); -{% endhighlight %} -Heads up! Should you ever need to remove a gradient, be sure to remove any IE-specific filter
you may have added. You can do that by using the .reset-filter()
mixin alongside background-image: none;
.
Utility mixins are mixins that combine otherwise unrelated CSS properties to achieve a specific goal or task.
- -Forget adding class="clearfix"
to any element and instead add the .clearfix()
mixin where appropriate. Uses the micro clearfix from Nicolas Gallager.
Quickly center any element within its parent. Requires width
or max-width
to be set.
Specify the dimensions of an object more easily.
-{% highlight scss %} -// Mixins -.size(@width; @height) { - width: @width; - height: @height; -} -.square(@size) { - .size(@size; @size); -} - -// Usage -.image { .size(400px; 300px); } -.avatar { .square(48px); } -{% endhighlight %} - -Easily configure the resize options for any textarea, or any other element. Defaults to normal browser behavior (both
).
Easily truncate text with an ellipsis with a single mixin. Requires element to be block
or inline-block
level.
Specify two image paths and the @1x image dimensions, and Bootstrap will provide an @2x media query. If you have many images to serve, consider writing your retina image CSS manually in a single media query.
-{% highlight scss %} -.img-retina(@file-1x; @file-2x; @width-1x; @height-1x) { - background-image: url("@{file-1x}"); - - @media - only screen and (-webkit-min-device-pixel-ratio: 2), - only screen and ( min--moz-device-pixel-ratio: 2), - only screen and ( -o-min-device-pixel-ratio: 2/1), - only screen and ( min-device-pixel-ratio: 2), - only screen and ( min-resolution: 192dpi), - only screen and ( min-resolution: 2dppx) { - background-image: url("@{file-2x}"); - background-size: @width-1x @height-1x; - } -} - -// Usage -.jumbotron { - .img-retina("/img/bg-1x.png", "/img/bg-2x.png", 100px, 100px); -} -{% endhighlight %} -While Bootstrap is built on Less, it also has an official Sass port. We maintain it in a separate GitHub repository and handle updates with a conversion script.
- -Since the Sass port has a separate repo and serves a slightly different audience, the contents of the project differ greatly from the main Bootstrap project. This ensures the Sass port is as compatible with as many Sass-based systems as possible.
- -Path | -Description | -
---|---|
lib/ |
- Ruby gem code (Sass configuration, Rails and Compass integrations) | -
tasks/ |
- Converter scripts (turning upstream Less to Sass) | -
test/ |
- Compilation tests | -
templates/ |
- Compass package manifest | -
vendor/assets/ |
- Sass, JavaScript, and font files | -
Rakefile |
- Internal tasks, such as rake and convert | -
Visit the Sass port's GitHub repository to see these files in action.
- - -For information on how to install and use Bootstrap for Sass, consult the GitHub repository readme. It's the most up to date source and includes information for use with Rails, Compass, and standard Sass projects.
- -As of Bootstrap 3.2, a right-to-left version of Bootstrap ships as part of the repository. It's powered by Twitter's CSS Flip project and is generated via our Gruntfile.
- -Bootstrap is by default a left-to-right project. For right-to-left projects, you'll need to set your language and replace the default Bootstrap CSS with an RTL version. First, set your language and text direction:
-{% highlight html %} - - -{% endhighlight %} -Then, include the right-to-left CSS file in place of the default Bootstrap CSS:
-{% highlight html %} - - -{% endhighlight %} -Alternatively, you may use the minified RTL file, bootstrap-rtl.min.css
.
CSS Flip is a project for converting left-to-right CSS files into right-to-left CSS files. We use it in our Gruntfile to automate the generation of Bootstrap's RTL CSS files.
-Bootstrap has a few easy ways to quickly get started, each one appealing to a different skill level and use case. Read through to see what suits your particular needs.
- -Compiled and minified CSS, JavaScript, and fonts. No docs or original source files are included.
- Download Bootstrap -Source Less, JavaScript, and font files, along with our docs. Requires a Less compiler and some setup.
- Download source -Bootstrap ported from Less to Sass for easy inclusion in Rails, Compass, or Sass-only projects.
- Download Sass -Currently v{{ site.current_version }}.
- -The folks over at MaxCDN graciously provide CDN support for Bootstrap's CSS and JavaScript. Just use these Bootstrap CDN links.
-{% highlight html %} - - - - - - - - -{% endhighlight %} - -Install and manage Bootstrap's Less, CSS, JavaScript, and fonts using Bower.
- {% highlight bash %}$ bower install bootstrap{% endhighlight %} -Bootstrap is downloadable in two forms, within which you'll find the following directories and files, logically grouping common resources and providing both compiled and minified variations.
- -Please note that all JavaScript plugins require jQuery to be included, as shown in the starter template. Consult our bower.json
to see which versions of jQuery are supported.
Once downloaded, unzip the compressed folder to see the structure of (the compiled) Bootstrap. You'll see something like this:
- -{% highlight bash %} -bootstrap/ -├── css/ -│ ├── bootstrap.css -│ ├── bootstrap.min.css -│ ├── bootstrap-theme.css -│ └── bootstrap-theme.min.css -├── js/ -│ ├── bootstrap.js -│ └── bootstrap.min.js -└── fonts/ - ├── glyphicons-halflings-regular.eot - ├── glyphicons-halflings-regular.svg - ├── glyphicons-halflings-regular.ttf - └── glyphicons-halflings-regular.woff -{% endhighlight %} - -This is the most basic form of Bootstrap: precompiled files for quick drop-in usage in nearly any web project. We provide compiled CSS and JS (bootstrap.*
), as well as compiled and minified CSS and JS (bootstrap.min.*
). Fonts from Glyphicons are included, as is the optional Bootstrap theme.
The Bootstrap source code download includes the precompiled CSS, JavaScript, and font assets, along with source Less, JavaScript, and documentation. More specifically, it includes the following and more:
-{% highlight bash %} -bootstrap/ -├── less/ -├── js/ -├── fonts/ -├── dist/ -│ ├── css/ -│ ├── js/ -│ └── fonts/ -└── docs/ - └── examples/ -{% endhighlight %} -The less/
, js/
, and fonts/
are the source code for our CSS, JS, and icon fonts (respectively). The dist/
folder includes everything listed in the precompiled download section above. The docs/
folder includes the source code for our documentation, and examples/
of Bootstrap usage. Beyond that, any other included file provides support for packages, license information, and development.
Start with this basic HTML template, or modify these examples. We hope you'll customize our templates and examples, adapting them to suit your needs.
- -Copy the HTML below to begin working with a minimal Bootstrap document.
-{% highlight html %} - - - - - - -Build on the basic template above with Bootstrap's many components. See also Customizing Bootstrap for tips on maintaining your own Bootstrap variants.
- -Nothing but the basics: compiled CSS and JavaScript along with a container.
-Build a more custom page by narrowing the default container and jumbotron.
-Super basic template that includes the navbar along with some additional content.
-Super basic template with a static top navbar along with some additional content.
-Super basic template with a fixed top navbar along with some additional content.
-Create a custom navbar with justified links. Heads up! Not too WebKit friendly.
-Attach a footer to the bottom of the viewport when the content is shorter than it.
-Attach a footer to the bottom of the viewport with a fixed navbar at the top.
-Stay up to date on the development of Bootstrap and reach out to the community with these helpful resources.
-irc.freenode.net
server, in the ##twitter-bootstrap channel.twitter-bootstrap-3
.You can also follow @twbootstrap on Twitter for the latest gossip and awesome music videos.
-Bootstrap automatically adapts your pages for various screen sizes. - Here's how to disable this feature so your page works like in this non-responsive example.
- -<meta>
mentioned in the CSS docswidth
on the .container
for each grid tier with a single width, for example width: 970px !important;
Be sure that this comes after the default Bootstrap CSS. You can optionally avoid the !important
with media queries or some selector-fu..col-xs-*
classes in addition to, or in place of, the medium/large ones. Don't worry, the extra-small device grid scales to all resolutions.You'll still need Respond.js for IE8 (since our media queries are still there and need to be processed). - This disables the "mobile site" aspects of Bootstrap.
- -We've applied these steps to an example. Read its source code to see the specific changes implemented.
- -Looking to migrate from an older version of Bootstrap to v3.x? Check out our migration guide.
Bootstrap is built to work best in the latest desktop and mobile browsers, meaning older browsers might display differently styled, though fully functional, renderings of certain components.
- -Specifically, we support the latest versions of the following browsers and platforms. On Windows, we support Internet Explorer 8-11. More specific support information is provided below.
-- | Chrome | -Firefox | -Internet Explorer | -Opera | -Safari | -
---|---|---|---|---|---|
Android | -Supported | -Not Supported | -N/A | -Not Supported | -N/A | -
iOS | -Supported | -N/A | -Not Supported | -Supported | -|
Mac OS X | -Supported | -Supported | -Supported | -Supported | -|
Windows | -Supported | -Supported | -Supported | -Supported | -Not Supported | -
Unofficially, Bootstrap should look and behave well enough in Chromium and Chrome for Linux, Firefox for Linux, and Internet Explorer 7, though they are not officially supported.
-For a list of some of the browser bugs that Bootstrap has to grapple with, see our Wall of browser bugs.
- -Internet Explorer 8 and 9 are also supported, however, please be aware that some CSS3 properties and HTML5 elements are not fully supported by these browsers. In addition, Internet Explorer 8 requires the use of Respond.js to enable media query support.
-Feature | -Internet Explorer 8 | -Internet Explorer 9 | -
---|---|---|
border-radius |
- Not supported | -Supported | -
box-shadow |
- Not supported | -Supported | -
transform |
- Not supported | - Supported, with -ms prefix |
-
transition |
- Not supported | -|
placeholder |
- Not supported | -
Visit Can I use... for details on browser support of CSS3 and HTML5 features.
- -Beware of the following caveats when using Respond.js in your development and production environments for Internet Explorer 8.
-Using Respond.js with CSS hosted on a different (sub)domain (for example, on a CDN) requires some additional setup. See the Respond.js docs for details.
-file://
Due to browser security rules, Respond.js doesn't work with pages viewed via the file://
protocol (like when opening a local HTML file). To test responsive features in IE8, view your pages over HTTP(S). See the Respond.js docs for details.
@import
Respond.js doesn't work with CSS that's referenced via @import
. In particular, some Drupal configurations are known to use @import
. See the Respond.js docs for details.
IE8 does not fully support box-sizing: border-box;
when combined with min-width
, max-width
, min-height
, or max-height
. For that reason, as of v3.0.1, we no longer use max-width
on .container
s.
Bootstrap is not supported in the old Internet Explorer compatibility modes. To be sure you're using the latest rendering mode for IE, consider including the appropriate <meta>
tag in your pages:
Confirm the document mode by opening the debugging tools: press F12 and check the "Document Mode".
-This tag is included in all Bootstrap's documentation and examples to ensure the best rendering possible in each supported version of Internet Explorer.
-See this StackOverflow question for more information.
- -Internet Explorer 10 doesn't differentiate device width from viewport width, and thus doesn't properly apply the media queries in Bootstrap's CSS. Normally you'd just add a quick snippet of CSS to fix this:
-{% highlight scss %} -@-ms-viewport { width: device-width; } -{% endhighlight %} -However, this doesn't work for devices running Windows Phone 8 versions older than Update 3 (a.k.a. GDR3), as it causes such devices to show a mostly desktop view instead of narrow "phone" view. To address this, you'll need to include the following CSS and JavaScript to work around the bug.
-{% highlight scss %} -@-webkit-viewport { width: device-width; } -@-moz-viewport { width: device-width; } -@-ms-viewport { width: device-width; } -@-o-viewport { width: device-width; } -@viewport { width: device-width; } -{% endhighlight %} - -{% highlight js %} -if (navigator.userAgent.match(/IEMobile\/10\.0/)) { - var msViewportStyle = document.createElement('style') - msViewportStyle.appendChild( - document.createTextNode( - '@-ms-viewport{width:auto!important}' - ) - ) - document.querySelector('head').appendChild(msViewportStyle) -} -{% endhighlight %} -For more information and usage guidelines, read Windows Phone 8 and Device-Width.
-As a heads up, we include this in the Bootstrap docs as an example.
- -As of Safari v7.0.1 for OS X and Safari for iOS v7.0.1, Safari's rendering engine has some trouble with the number of decimal places used in our .col-*-1
grid classes. So if you have 12 individual grid columns, you'll notice that they come up short compared to other rows of columns. We can't do much here (see #9282) but you do have some options:
.pull-right
to your last grid column to get the hard-right alignmentWe'll keep an eye on this though and update our code if we have an easy solution.
- -Support for overflow: hidden
on the <body>
element is quite limited in iOS and Android. To that end, when you scroll past the top or bottom of a modal in either of those devices' browsers, the <body>
content will begin to scroll.
Also, note that if you're using inputs in your modal or navbar, iOS has a rendering bug that doesn't update the position of fixed elements when the virtual keyboard is triggered. A few workarounds for this include transforming your elements to position: absolute
or invoking a timer on focus to try to correct the positioning manually. This is not handled by Bootstrap, so it is up to you to decide which solution is best for your application.
The .dropdown-backdrop
element isn't used on iOS in the nav because of the complexity of z-indexing. Thus, to close dropdowns in navbars, you must directly click the dropdown element (or any other element which will fire a click event in iOS).
Page zooming inevitably presents rendering artifacts in some components, both in Bootstrap and the rest of the web. Depending on the issue, we may be able to fix it (search first and then open an issue if need be). However, we tend to ignore these as they often have no direct solution other than hacky workarounds.
- -Even in some modern browsers, printing can be quirky. In particular, as of Chrome v32 and regardless of margin settings, Chrome uses a viewport width significantly narrower than the physical paper size when resolving media queries while printing a webpage. This can result in Bootstrap's extra-small grid being unexpectedly activated when printing. See #12078 for some details. Suggested workarounds:
-@screen-*
Less variables so that your printer paper is considered larger than extra-small.Out of the box, Android 4.1 (and even some newer releases apparently) ship with the Browser app as the default web browser of choice (as opposed to Chrome). Unfortunately, the Browser app has lots of bugs and inconsistencies with CSS in general.
-On <select>
elements, the Android stock browser will not display the side controls if there is a border-radius
and/or border
applied. Use the snippet of code below to remove the offending CSS and render the <select>
as an unstyled element on the Android stock browser. The user agent sniffing avoids interference with Chrome, Safari, and Mozilla browsers.
Want to see an example? Check out this JS Bin demo.
-While we don't officially support any third party plugins or add-ons, we do offer some useful advice to help avoid potential issues in your projects.
- -Some third party software, including Google Maps and Google Custom Search Engine, conflict with Bootstrap due to * { box-sizing: border-box; }
, a rule which makes it so padding
does not affect the final computed width of an element. Learn more about box model and sizing at CSS Tricks.
Depending on the context, you may override as-needed (Option 1) or reset the box-sizing for entire regions (Option 2).
-{% highlight scss %} -/* Box-sizing resets - * - * Reset individual elements or override regions to avoid conflicts due to - * global box model settings of Bootstrap. Two options, individual overrides and - * region resets, are available as plain CSS and uncompiled Less formats. - */ - -/* Option 1A: Override a single element's box model via CSS */ -.element { - -webkit-box-sizing: content-box; - -moz-box-sizing: content-box; - box-sizing: content-box; -} - -/* Option 1B: Override a single element's box model by using a Bootstrap Less mixin */ -.element { - .box-sizing(content-box); -} - -/* Option 2A: Reset an entire region via CSS */ -.reset-box-sizing, -.reset-box-sizing *, -.reset-box-sizing *:before, -.reset-box-sizing *:after { - -webkit-box-sizing: content-box; - -moz-box-sizing: content-box; - box-sizing: content-box; -} - -/* Option 2B: Reset an entire region with a custom Less mixin */ -.reset-box-sizing { - &, - *, - *:before, - *:after { - .box-sizing(content-box); - } -} -.element { - .reset-box-sizing(); -} -{% endhighlight %} -Bootstrap follows common web standards and—with minimal extra effort—can be used to create sites that are accessible to those using AT.
- -If your navigation contains many links and comes before the main content in the DOM, add a Skip to main content
link immediately after your opening <body>
tag. (read why)
When nesting headings (<h1>
- <h6>
), your primary document header should be an <h1>
. Subsequent headings should make logical use of <h2>
- <h6>
such that screen readers can construct a table of contents for your pages.
Learn more at HTML CodeSniffer and Penn State's AccessAbility.
- -Bootstrap is released under the MIT license and is copyright {{ site.time | date: "%Y" }} Twitter. Boiled down to smaller chunks, it can be described with the following conditions.
- -The full Bootstrap license is located in the project repository for more information.
-Bootstrap is best maintained when you treat it as a separate and independently-versioned dependency in your development environment. Doing this makes upgrading Bootstrap easier in the future.
- -Once you've downloaded and included Bootstrap's styles and scripts, you can customize its components. Just create a new stylesheet (Less, if you like, or just plain CSS) to house your customizations.
- -Unless you plan on reading the CSS, go with minified stylesheets. It's the same code, just compacted. Minified styles use less bandwidth, which is good, especially in production environments.
-From there, include whatever Bootstrap components and HTML content you need to create templates for your site's pages.
- -You can customize components to varying degrees, but most fall into two camps: light customizations and overhauls. Plenty examples of both are available from third parties.
-We define light customizations as superficial changes, for example, color and font changes to existing Bootstrap components. A light customization example is the Twitter Translation Center (coded by @mdo). Let's look at how to implement the custom button we wrote for this site, .btn-ttc
.
The stock Bootstrap buttons require just one class, .btn
, to start. Here we extend the .btn
style with a new modifier class, .btn-ttc
, that we will create. This gives us a distinct custom look with minimal effort.
Our customized button will be coded like this:
-{% highlight html %} - -{% endhighlight %} -Note how .btn-ttc
is added to the standard .btn
class.
To implement this, in the custom stylesheet, add the following CSS:
- -{% highlight scss %} -/* Custom button --------------------------------------------------- */ - -/* Override base .btn styles */ -/* Apply text and background changes to three key states: default, hover, and active (click). */ -.btn-ttc, -.btn-ttc:hover, -.btn-ttc:active { - color: white; - text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25); - background-color: #007da7; -} - -/* Apply the custom-colored gradients */ -/* Note: you'll need to include all the appropriate gradients for various browsers and standards. */ -.btn-ttc { - background-repeat: repeat-x; - background-image: linear-gradient(top, #009ED2 0%, #007DA7 100%); - ... -} - -/* Set the hover state */ -/* An easy hover state is just to move the gradient up a small amount. Add other embellishments as you see fit. */ -.btn-ttc:hover { - background-position: 0 -15px; -} -{% endhighlight %} - -In short: Look to the style source and duplicate the selectors you need for your modifications.
-In summary, here's the basic workflow:
-.navbar
style specification.!important
here. Keep it simple.Once you are comfortable performing light customizations, visual overhauls are just as straightforward. For a site like Karma, which uses Bootstrap as a CSS reset with heavy modifications, more extensive work is involved. But the same principle applies: include Bootstrap's default stylesheet first, then apply your custom stylesheet.
- -While not recommended for folks new to Bootstrap, you may use one of two alternate methods for customization. The first is modifying the source .less
files (making upgrades super difficult), and the second is mapping source Less code to your own classes via mixins. For the time being, neither of those options are documented here.
Not all sites and applications need to make use of everything Bootstrap has to offer, especially in production environments where optimizing bandwidth is an issue. We encourage you to remove whatever is unused with our Customizer.
-Using the Customizer, simply uncheck any component, feature, or asset you don't need. Hit download and swap out the default Bootstrap files with these newly customized ones. You'll get vanilla Bootstrap, but without the features *you* deem unnecessary. All custom builds include compiled and minified versions, so use whichever works for you.
-Community members have translated Bootstrap's documentation into various languages. None are officially supported and they may not always be up to date.
-We don't help organize or host translations, we just link to them.
-Finished a new or better translation? Open a pull request to add it to our list.
-Plugins can be included individually (using Bootstrap's individual *.js
files), or all at once (using bootstrap.js
or the minified bootstrap.min.js
).
Both bootstrap.js
and bootstrap.min.js
contain all plugins in a single file. Include only one.
Don't use data attributes from multiple plugins on the same element. For example, a button cannot both have a tooltip and toggle a modal. To accomplish this, use a wrapping element.
-Some plugins and CSS components depend on other plugins. If you include plugins individually, make sure to check for these dependencies in the docs. Also note that all plugins depend on jQuery (this means jQuery must be included before the plugin files). Consult our bower.json
to see which versions of jQuery are supported.
You can use all Bootstrap plugins purely through the markup API without writing a single line of JavaScript. This is Bootstrap's first-class API and should be your first consideration when using a plugin.
- -That said, in some situations it may be desirable to turn this functionality off. Therefore, we also provide the ability to disable the data attribute API by unbinding all events on the document namespaced with data-api
. This looks like this:
Alternatively, to target a specific plugin, just include the plugin's name as a namespace along with the data-api namespace like this:
-{% highlight js %} -$(document).off('.alert.data-api') -{% endhighlight %} - -We also believe you should be able to use all Bootstrap plugins purely through the JavaScript API. All public APIs are single, chainable methods, and return the collection acted upon.
-{% highlight js %} -$('.btn.danger').button('toggle').addClass('fat') -{% endhighlight %} - -All methods should accept an optional options object, a string which targets a particular method, or nothing (which initiates a plugin with default behavior):
-{% highlight js %} -$('#myModal').modal() // initialized with defaults -$('#myModal').modal({ keyboard: false }) // initialized with no keyboard -$('#myModal').modal('show') // initializes and invokes show immediately -{% endhighlight %} - -Each plugin also exposes its raw constructor on a Constructor
property: $.fn.popover.Constructor
. If you'd like to get a particular plugin instance, retrieve it directly from an element: $('[rel=popover]').data('popover')
.
Sometimes it is necessary to use Bootstrap plugins with other UI frameworks. In these circumstances, namespace collisions can occasionally occur. If this happens, you may call .noConflict
on the plugin you wish to revert the value of.
Bootstrap provides custom events for most plugins' unique actions. Generally, these come in an infinitive and past participle form - where the infinitive (ex. show
) is triggered at the start of an event, and its past participle form (ex. shown
) is triggered on the completion of an action.
As of 3.0.0, all Bootstrap events are namespaced.
-All infinitive events provide preventDefault
functionality. This provides the ability to stop the execution of an action before it starts.
Bootstrap does not officially support third-party JavaScript libraries like Prototype or jQuery UI. Despite .noConflict
and namespaced events, there may be compatibility problems that you need to fix on your own.
For simple transition effects, include transition.js
once alongside the other JS files. If you're using the compiled (or minified) bootstrap.js
, there is no need to include this—it's already there.
Transition.js is a basic helper for transitionEnd
events as well as a CSS transition emulator. It's used by the other plugins to check for CSS transition support and to catch hanging transitions.
Modals are streamlined, but flexible, dialog prompts with the minimum required functionality and smart defaults.
- -Be sure not to open a modal while another is still visible. Showing more than one modal at a time requires custom code.
-Always try to place a modal's HTML code in a top-level position in your document to avoid other components affecting the modal's appearance and/or functionality.
-There are some caveats regarding using modals on mobile devices. See our browser support docs for details.
-A rendered modal with header, body, and set of actions in the footer.
-Toggle a modal via JavaScript by clicking the button below. It will slide down and fade in from the top of the page.
- - - -Be sure to add role="dialog"
to .modal
, aria-labelledby="myModalLabel"
attribute to reference the modal title, and aria-hidden="true"
to tell assistive technologies to skip the modal's DOM elements.
Additionally, you may give a description of your modal dialog with aria-describedby
on .modal
.
Embedding YouTube videos in modals requires additional JavaScript not in Bootstrap to automatically stop playback and more. See this helpful Stack Overflow post for more information.
-Modals have two optional sizes, available via modifier classes to be placed on a .modal-dialog
.
For modals that simply appear rather than fade in to view, remove the .fade
class from your modal markup.
The modal plugin toggles your hidden content on demand, via data attributes or JavaScript. It also adds .modal-open
to the <body>
to override default scrolling behavior and generates a .modal-backdrop
to provide a click area for dismissing shown modals when clicking outside the modal.
Activate a modal without writing JavaScript. Set data-toggle="modal"
on a controller element, like a button, along with a data-target="#foo"
or href="#foo"
to target a specific modal to toggle.
Call a modal with id myModal
with a single line of JavaScript:
Options can be passed via data attributes or JavaScript. For data attributes, append the option name to data-
, as in data-backdrop=""
.
Name | -type | -default | -description | -
---|---|---|---|
backdrop | -boolean or the string 'static' |
- true | -Includes a modal-backdrop element. Alternatively, specify static for a backdrop which doesn't close the modal on click. |
-
keyboard | -boolean | -true | -Closes the modal when escape key is pressed | -
show | -boolean | -true | -Shows the modal when initialized. | -
remote | -path | -false | -If a remote URL is provided, content will be loaded one time via jQuery's |
-
Activates your content as a modal. Accepts an optional options object
.
Manually toggles a modal. Returns to the caller before the modal has actually been shown or hidden (i.e. before the shown.bs.modal
or hidden.bs.modal
event occurs).
Manually opens a modal. Returns to the caller before the modal has actually been shown (i.e. before the shown.bs.modal
event occurs).
Manually hides a modal. Returns to the caller before the modal has actually been hidden (i.e. before the hidden.bs.modal
event occurs).
Bootstrap's modal class exposes a few events for hooking into modal functionality.
-Event Type | -Description | -
---|---|
show.bs.modal | -This event fires immediately when the show instance method is called. If caused by a click, the clicked element is available as the relatedTarget property of the event. |
-
shown.bs.modal | -This event is fired when the modal has been made visible to the user (will wait for CSS transitions to complete). If caused by a click, the clicked element is available as the relatedTarget property of the event. |
-
hide.bs.modal | -This event is fired immediately when the hide instance method has been called. |
-
hidden.bs.modal | -This event is fired when the modal has finished being hidden from the user (will wait for CSS transitions to complete). | -
loaded.bs.modal | -This event is fired when the modal has loaded content using the remote option. | -
Add dropdown menus to nearly anything with this simple plugin, including the navbar, tabs, and pills.
- -Via data attributes or JavaScript, the dropdown plugin toggles hidden content (dropdown menus) by toggling the .open
class on the parent list item. When opened, the plugin also adds .dropdown-backdrop
as a click area for closing dropdown menus when clicking outside the menu. Note: The data-toggle=dropdown
attribute is relied on for closing dropdown menus at an application level, so it's a good idea to always use it.
Add data-toggle="dropdown"
to a link or button to toggle a dropdown.
To keep URLs intact, use the data-target
attribute instead of href="#"
.
Call the dropdowns via JavaScript:
-{% highlight js %} -$('.dropdown-toggle').dropdown() -{% endhighlight %} -data-toggle="dropdown"
still requiredRegardless of whether you call your dropdown via JavaScript or instead use the data-api, data-toggle="dropdown"
is always required to be present on the dropdown's trigger element.
None
- -Toggles the dropdown menu of a given navbar or tabbed navigation.
- -All dropdown events are fired at the .dropdown-menu
's parent element.
Event Type | -Description | -
---|---|
show.bs.dropdown | -This event fires immediately when the show instance method is called. The toggling anchor element is available as the relatedTarget property of the event. |
-
shown.bs.dropdown | -This event is fired when the dropdown has been made visible to the user (will wait for CSS transitions, to complete). The toggling anchor element is available as the relatedTarget property of the event. |
-
hide.bs.dropdown | -This event is fired immediately when the hide instance method has been called. The toggling anchor element is available as the relatedTarget property of the event. |
-
hidden.bs.dropdown | -This event is fired when the dropdown has finished being hidden from the user (will wait for CSS transitions, to complete). The toggling anchor element is available as the relatedTarget property of the event. |
-
The ScrollSpy plugin is for automatically updating nav targets based on scroll position. Scroll the area below the navbar and watch the active class change. The dropdown sub items will be highlighted as well.
-Ad leggings keytar, brunch id art party dolor labore. Pitchfork yr enim lo-fi before they sold out qui. Tumblr farm-to-table bicycle rights whatever. Anim keffiyeh carles cardigan. Velit seitan mcsweeney's photo booth 3 wolf moon irure. Cosby sweater lomo jean shorts, williamsburg hoodie minim qui you probably haven't heard of them et cardigan trust fund culpa biodiesel wes anderson aesthetic. Nihil tattooed accusamus, cred irony biodiesel keffiyeh artisan ullamco consequat.
-Veniam marfa mustache skateboard, adipisicing fugiat velit pitchfork beard. Freegan beard aliqua cupidatat mcsweeney's vero. Cupidatat four loko nisi, ea helvetica nulla carles. Tattooed cosby sweater food truck, mcsweeney's quis non freegan vinyl. Lo-fi wes anderson +1 sartorial. Carles non aesthetic exercitation quis gentrify. Brooklyn adipisicing craft beer vice keytar deserunt.
-Occaecat commodo aliqua delectus. Fap craft beer deserunt skateboard ea. Lomo bicycle rights adipisicing banh mi, velit ea sunt next level locavore single-origin coffee in magna veniam. High life id vinyl, echo park consequat quis aliquip banh mi pitchfork. Vero VHS est adipisicing. Consectetur nisi DIY minim messenger bag. Cred ex in, sustainable delectus consectetur fanny pack iphone.
-In incididunt echo park, officia deserunt mcsweeney's proident master cleanse thundercats sapiente veniam. Excepteur VHS elit, proident shoreditch +1 biodiesel laborum craft beer. Single-origin coffee wayfarers irure four loko, cupidatat terry richardson master cleanse. Assumenda you probably haven't heard of them art party fanny pack, tattooed nulla cardigan tempor ad. Proident wolf nesciunt sartorial keffiyeh eu banh mi sustainable. Elit wolf voluptate, lo-fi ea portland before they sold out four loko. Locavore enim nostrud mlkshk brooklyn nesciunt.
-Ad leggings keytar, brunch id art party dolor labore. Pitchfork yr enim lo-fi before they sold out qui. Tumblr farm-to-table bicycle rights whatever. Anim keffiyeh carles cardigan. Velit seitan mcsweeney's photo booth 3 wolf moon irure. Cosby sweater lomo jean shorts, williamsburg hoodie minim qui you probably haven't heard of them et cardigan trust fund culpa biodiesel wes anderson aesthetic. Nihil tattooed accusamus, cred irony biodiesel keffiyeh artisan ullamco consequat.
-Keytar twee blog, culpa messenger bag marfa whatever delectus food truck. Sapiente synth id assumenda. Locavore sed helvetica cliche irony, thundercats you probably haven't heard of them consequat hoodie gluten-free lo-fi fap aliquip. Labore elit placeat before they sold out, terry richardson proident brunch nesciunt quis cosby sweater pariatur keffiyeh ut helvetica artisan. Cardigan craft beer seitan readymade velit. VHS chambray laboris tempor veniam. Anim mollit minim commodo ullamco thundercats. -
-No matter the implementation method, scrollspy requires the use of position: relative;
on the element you're spying on. In most cases this is the <body>
.
To easily add scrollspy behavior to your topbar navigation, add data-spy="scroll"
to the element you want to spy on (most typically this would be the <body>
). Then add the data-target
attribute with the ID or class of the parent element of any Bootstrap .nav
component.
After adding position: relative;
in your CSS, call the scrollspy via JavaScript:
Navbar links must have resolvable id targets. For example, a <a href="#home">home</a>
must correspond to something in the DOM like <div id="home"></div>
.
When using scrollspy in conjunction with adding or removing of elements from the DOM, you'll need to call the refresh method like so:
-{% highlight js %} -$('[data-spy="scroll"]').each(function () { - var $spy = $(this).scrollspy('refresh') -}) -{% endhighlight %} - - -Options can be passed via data attributes or JavaScript. For data attributes, append the option name to data-
, as in data-offset=""
.
Name | -type | -default | -description | -
---|---|---|---|
offset | -number | -10 | -Pixels to offset from top when calculating position of scroll. | -
Event Type | -Description | -
---|---|
activate.bs.scrollspy | -This event fires whenever a new item becomes activated by the scrollspy. | -
Add quick, dynamic tab functionality to transition through panes of local content, even via dropdown menus.
-Raw denim you probably haven't heard of them jean shorts Austin. Nesciunt tofu stumptown aliqua, retro synth master cleanse. Mustache cliche tempor, williamsburg carles vegan helvetica. Reprehenderit butcher retro keffiyeh dreamcatcher synth. Cosby sweater eu banh mi, qui irure terry richardson ex squid. Aliquip placeat salvia cillum iphone. Seitan aliquip quis cardigan american apparel, butcher voluptate nisi qui.
-Food truck fixie locavore, accusamus mcsweeney's marfa nulla single-origin coffee squid. Exercitation +1 labore velit, blog sartorial PBR leggings next level wes anderson artisan four loko farm-to-table craft beer twee. Qui photo booth letterpress, commodo enim craft beer mlkshk aliquip jean shorts ullamco ad vinyl cillum PBR. Homo nostrud organic, assumenda labore aesthetic magna delectus mollit. Keytar helvetica VHS salvia yr, vero magna velit sapiente labore stumptown. Vegan fanny pack odio cillum wes anderson 8-bit, sustainable jean shorts beard ut DIY ethical culpa terry richardson biodiesel. Art party scenester stumptown, tumblr butcher vero sint qui sapiente accusamus tattooed echo park.
-Etsy mixtape wayfarers, ethical wes anderson tofu before they sold out mcsweeney's organic lomo retro fanny pack lo-fi farm-to-table readymade. Messenger bag gentrify pitchfork tattooed craft beer, iphone skateboard locavore carles etsy salvia banksy hoodie helvetica. DIY synth PBR banksy irony. Leggings gentrify squid 8-bit cred pitchfork. Williamsburg banh mi whatever gluten-free, carles pitchfork biodiesel fixie etsy retro mlkshk vice blog. Scenester cred you probably haven't heard of them, vinyl craft beer blog stumptown. Pitchfork sustainable tofu synth chambray yr.
-Trust fund seitan letterpress, keytar raw denim keffiyeh etsy art party before they sold out master cleanse gluten-free squid scenester freegan cosby sweater. Fanny pack portland seitan DIY, art party locavore wolf cliche high life echo park Austin. Cred vinyl keffiyeh DIY salvia PBR, banh mi before they sold out farm-to-table VHS viral locavore cosby sweater. Lomo wolf viral, mustache readymade thundercats keffiyeh craft beer marfa ethical. Wolf salvia freegan, sartorial keffiyeh echo park vegan.
-This plugin extends the tabbed navigation component to add tabbable areas.
-Enable tabbable tabs via JavaScript (each tab needs to be activated individually):
- -{% highlight js %} -$('#myTab a').click(function (e) { - e.preventDefault() - $(this).tab('show') -}) -{% endhighlight %} - -You can activate individual tabs in several ways:
- -{% highlight js %} -$('#myTab a[href="#profile"]').tab('show') // Select tab by name -$('#myTab a:first').tab('show') // Select first tab -$('#myTab a:last').tab('show') // Select last tab -$('#myTab li:eq(2) a').tab('show') // Select third tab (0-indexed) -{% endhighlight %} - -You can activate a tab or pill navigation without writing any JavaScript by simply specifying data-toggle="tab"
or data-toggle="pill"
on an element. Adding the nav
and nav-tabs
classes to the tab ul
will apply the Bootstrap tab styling, while adding the nav
and nav-pills
classes will apply pill styling.
To make tabs fade in, add .fade
to each .tab-pane
. The first tab pane must also have .in
to properly fade in initial content.
- Activates a tab element and content container. Tab should have either a data-target
or an href
targeting a container node in the DOM.
-
Event Type | -Description | -
---|---|
show.bs.tab | -This event fires on tab show, but before the new tab has been shown. Use event.target and event.relatedTarget to target the active tab and the previous active tab (if available) respectively. |
-
shown.bs.tab | -This event fires on tab show after a tab has been shown. Use event.target and event.relatedTarget to target the active tab and the previous active tab (if available) respectively. |
-
Inspired by the excellent jQuery.tipsy plugin written by Jason Frame; Tooltips are an updated version, which don't rely on images, use CSS3 for animations, and data-attributes for local title storage.
-Hover over the links below to see tooltips:
-Tight pants next level keffiyeh you probably haven't heard of them. Photo booth beard raw denim letterpress vegan messenger bag stumptown. Farm-to-table seitan, mcsweeney's fixie sustainable quinoa 8-bit american apparel have a terry richardson vinyl chambray. Beard stumptown, cardigans banh mi lomo thundercats. Tofu biodiesel williamsburg marfa, four loko mcsweeney's cleanse vegan chambray. A really ironic artisan whatever keytar, scenester farm-to-table banksy Austin twitter handle freegan cred raw denim single-origin coffee viral. -
-For performance reasons, the Tooltip and Popover data-apis are opt-in, meaning you must initialize them yourself.
-When using tooltips on elements within a .btn-group
or an .input-group
, you'll have to specify the option container: 'body'
(documented below) to avoid unwanted side effects (such as the element growing wider and/or losing its rounded corners when the tooltip is triggered).
To add a tooltip to a disabled
or .disabled
element, put the element inside of a <div>
and apply the tooltip to that <div>
instead.
The tooltip plugin generates content and markup on demand, and by default places tooltips after their trigger element.
-Trigger the tooltip via JavaScript:
-{% highlight js %} -$('#example').tooltip(options) -{% endhighlight %} - -The required markup for a tooltip is only a data
attribute and title
on the HTML element you wish to have a tooltip. The generated markup of a tooltip is rather simple, though it does require a position (by default, set to top
by the plugin).
Sometimes you want to add a tooltip to a hyperlink that wraps multiple lines. The default behavior of the tooltip plugin is to center it horizontally and vertically. Add white-space: nowrap;
to your anchors to avoid this.
Options can be passed via data attributes or JavaScript. For data attributes, append the option name to data-
, as in data-animation=""
.
Name | -type | -default | -description | -
---|---|---|---|
animation | -boolean | -true | -apply a CSS fade transition to the tooltip | -
html | -boolean | -false | -Insert HTML into the tooltip. If false, jQuery's text method will be used to insert content into the DOM. Use text if you're worried about XSS attacks. |
-
placement | -string | function | -'top' | -how to position the tooltip - top | bottom | left | right | auto. When "auto" is specified, it will dynamically reorient the tooltip. For example, if placement is "auto left", the tooltip will display to the left when possible, otherwise it will display right. |
-
selector | -string | -false | -If a selector is provided, tooltip objects will be delegated to the specified targets. | -
title | -string | function | -'' | -default title value if title attribute isn't present |
-
trigger | -string | -'hover focus' | -how tooltip is triggered - click | hover | focus | manual. You may pass multiple triggers; separate them with a space. | -
delay | -number | object | -0 | -
- delay showing and hiding the tooltip (ms) - does not apply to manual trigger type -If a number is supplied, delay is applied to both hide/show -Object structure is: |
-
container | -string | false | -false | -
- Appends the tooltip to a specific element. Example: |
-
Options for individual tooltips can alternatively be specified through the use of data attributes, as explained above.
-Attaches a tooltip handler to an element collection.
- -Reveals an element's tooltip.
- {% highlight js %}$('#element').tooltip('show'){% endhighlight %} - -Hides an element's tooltip.
- {% highlight js %}$('#element').tooltip('hide'){% endhighlight %} - -Toggles an element's tooltip.
- {% highlight js %}$('#element').tooltip('toggle'){% endhighlight %} - -Hides and destroys an element's tooltip.
- {% highlight js %}$('#element').tooltip('destroy'){% endhighlight %} - -Event Type | -Description | -
---|---|
show.bs.tooltip | -This event fires immediately when the show instance method is called. |
-
shown.bs.tooltip | -This event is fired when the tooltip has been made visible to the user (will wait for CSS transitions to complete). | -
hide.bs.tooltip | -This event is fired immediately when the hide instance method has been called. |
-
hidden.bs.tooltip | -This event is fired when the tooltip has finished being hidden from the user (will wait for CSS transitions to complete). | -
Add small overlays of content, like those on the iPad, to any element for housing secondary information.
- -Popovers require the tooltip plugin to be included in your version of Bootstrap.
-For performance reasons, the Tooltip and Popover data-apis are opt-in, meaning you must initialize them yourself.
-When using popovers on elements within a .btn-group
or an .input-group
, you'll have to specify the option container: 'body'
(documented below) to avoid unwanted side effects (such as the element growing wider and/or losing its rounded corners when the popover is triggered).
To add a popover to a disabled
or .disabled
element, put the element inside of a <div>
and apply the popover to that <div>
instead.
Four options are available: top, right, bottom, and left aligned.
-Sed posuere consectetur est at lobortis. Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum.
-Sed posuere consectetur est at lobortis. Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum.
-Sed posuere consectetur est at lobortis. Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum.
-Sed posuere consectetur est at lobortis. Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum.
-Use the focus
trigger to dismiss popovers on their next click.
Sometimes you want to add a popover to a hyperlink that wraps multiple lines. The default behavior of the popover plugin is to center it horizontally and vertically. Add white-space: nowrap;
to your anchors to avoid this.
Enable popovers via JavaScript:
- {% highlight js %}$('#example').popover(options){% endhighlight %} - -Options can be passed via data attributes or JavaScript. For data attributes, append the option name to data-
, as in data-animation=""
.
Name | -type | -default | -description | -
---|---|---|---|
animation | -boolean | -true | -apply a CSS fade transition to the popover | -
html | -boolean | -false | -Insert HTML into the popover. If false, jQuery's text method will be used to insert content into the DOM. Use text if you're worried about XSS attacks. |
-
placement | -string | function | -'right' | -how to position the popover - top | bottom | left | right | auto. When "auto" is specified, it will dynamically reorient the popover. For example, if placement is "auto left", the popover will display to the left when possible, otherwise it will display right. |
-
selector | -string | -false | -if a selector is provided, popover objects will be delegated to the specified targets. In practice, this is used to enable dynamic HTML content to have popovers added. See this and an informative example. | -
trigger | -string | -'click' | -how popover is triggered - click | hover | focus | manual | -
title | -string | function | -'' | -default title value if title attribute isn't present |
-
content | -string | function | -'' | -default content value if data-content attribute isn't present |
-
delay | -number | object | -0 | -
- delay showing and hiding the popover (ms) - does not apply to manual trigger type -If a number is supplied, delay is applied to both hide/show -Object structure is: |
-
container | -string | false | -false | -
- Appends the popover to a specific element. Example: |
-
Options for individual popovers can alternatively be specified through the use of data attributes, as explained above.
-Initializes popovers for an element collection.
- -Reveals an elements popover.
- {% highlight js %}$('#element').popover('show'){% endhighlight %} - -Hides an elements popover.
- {% highlight js %}$('#element').popover('hide'){% endhighlight %} - -Toggles an elements popover.
- {% highlight js %}$('#element').popover('toggle'){% endhighlight %} - -Hides and destroys an element's popover.
- {% highlight js %}$('#element').popover('destroy'){% endhighlight %} -Event Type | -Description | -
---|---|
show.bs.popover | -This event fires immediately when the show instance method is called. |
-
shown.bs.popover | -This event is fired when the popover has been made visible to the user (will wait for CSS transitions to complete). | -
hide.bs.popover | -This event is fired immediately when the hide instance method has been called. |
-
hidden.bs.popover | -This event is fired when the popover has finished being hidden from the user (will wait for CSS transitions to complete). | -
Add dismiss functionality to all alert messages with this plugin.
-Change this and that and try again. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit. Cras mattis consectetur purus sit amet fermentum.
-- - -
-Enable dismissal of an alert via JavaScript:
- {% highlight js %}$(".alert").alert(){% endhighlight %} - -Just add data-dismiss="alert"
to your close button to automatically give an alert close functionality.
Wraps all alerts with close functionality. To have your alerts animate out when closed, make sure they have the .fade
and .in
class already applied to them.
Closes an alert.
- {% highlight js %}$(".alert").alert('close'){% endhighlight %} - - -Bootstrap's alert class exposes a few events for hooking into alert functionality.
-Event Type | -Description | -
---|---|
close.bs.alert | -This event fires immediately when the close instance method is called. |
-
closed.bs.alert | -This event is fired when the alert has been closed (will wait for CSS transitions to complete). | -
Do more with buttons. Control button states or create groups of buttons for more components like toolbars.
- -Add data-loading-text="Loading..."
to use a loading state on a button.
Add data-toggle="button"
to activate toggling on a single button.
Add data-toggle="buttons"
to a group of checkboxes for checkbox style toggling on btn-group.
Add data-toggle="buttons"
to a group of radio inputs for radio style toggling on btn-group.
Enable buttons via JavaScript:
-{% highlight js %} -$('.btn').button() -{% endhighlight %} - -Data attributes are integral to the button plugin. Check out the example code below for the various markup types.
- -None
- -Toggles push state. Gives the button the appearance that it has been activated.
-You can enable auto toggling of a button by using the data-toggle
attribute.
Sets button state to loading - disables button and swaps text to loading text. Loading text should be defined on the button element using the data attribute data-loading-text
.
-
Firefox persists the disabled state across page loads. A workaround for this is to use autocomplete="off"
.
Resets button state - swaps text to original text.
- -Resets button state - swaps text to any data defined text state.
-{% highlight html %} - - -{% endhighlight %} -Get base styles and flexible support for collapsible components like accordions and navigation.
- -Collapse requires the transitions plugin to be included in your version of Bootstrap.
-Using the collapse plugin, we built a simple accordion by extending the panel component.
- -You can also use the plugin without the accordion markup. Make a button toggle the expanding and collapsing of another element.
-{% highlight html %} - - -The collapse plugin utilizes a few classes to handle the heavy lifting:
-.collapse
hides the content.collapse.in
shows the content.collapsing
is added when the transition starts, and removed when it finishesThese classes can be found in component-animations.less
.
Just add data-toggle="collapse"
and a data-target
to element to automatically assign control of a collapsible element. The data-target
attribute accepts a CSS selector to apply the collapse to. Be sure to add the class collapse
to the collapsible element. If you'd like it to default open, add the additional class in
.
To add accordion-like group management to a collapsible control, add the data attribute data-parent="#selector"
. Refer to the demo to see this in action.
Enable manually with:
-{% highlight js %} -$('.collapse').collapse() -{% endhighlight %} - -Options can be passed via data attributes or JavaScript. For data attributes, append the option name to data-
, as in data-parent=""
.
Name | -type | -default | -description | -
---|---|---|---|
parent | -selector | -false | -If selector then all collapsible elements under the specified parent will be closed when this collapsible item is shown. (similar to traditional accordion behavior - this dependent on the panel class) |
-
toggle | -boolean | -true | -Toggles the collapsible element on invocation | -
Activates your content as a collapsible element. Accepts an optional options object
.
-{% highlight js %}
-$('#myCollapsible').collapse({
- toggle: false
-})
-{% endhighlight %}
-
-
Toggles a collapsible element to shown or hidden.
- -Shows a collapsible element.
- -Hides a collapsible element.
- -Bootstrap's collapse class exposes a few events for hooking into collapse functionality.
-Event Type | -Description | -
---|---|
show.bs.collapse | -This event fires immediately when the show instance method is called. |
-
shown.bs.collapse | -This event is fired when a collapse element has been made visible to the user (will wait for CSS transitions to complete). | -
hide.bs.collapse | -
- This event is fired immediately when the hide method has been called.
- |
-
hidden.bs.collapse | -This event is fired when a collapse element has been hidden from the user (will wait for CSS transitions to complete). | -
The slideshow below shows a generic plugin and component for cycling through elements like a carousel.
-Bootstrap exclusively uses CSS3 for its animations, but Internet Explorer 8 & 9 don't support the necessary CSS properties. Thus, there are no slide transition animations when using these browsers. We have intentionally decided not to include jQuery-based fallbacks for the transitions.
-Add captions to your slides easily with the .carousel-caption
element within any .item
. Place just about any optional HTML within there and it will be automatically aligned and formatted.
...
-The carousel component is generally not compliant with accessibility standards. If you need to be compliant, please consider other options for presenting your content.
-Carousels require the use of an id
on the outermost container, .carousel
, for carousel controls to function properly. When adding multiple carousels, or when changing a carousel's id
, be sure to update the relevant controls.
Use data attributes to easily control the position of the carousel. data-slide
accepts the keywords prev
or next
, which alters the slide position relative to its current position. Alternatively, use data-slide-to
to pass a raw slide index to the carousel data-slide-to="2"
, which shifts the slide position to a particular index beginning with 0
.
The data-ride="carousel"
attribute is used to mark a carousel as animating starting at page load.
Call carousel manually with:
-{% highlight js %} -$('.carousel').carousel() -{% endhighlight %} - -Options can be passed via data attributes or JavaScript. For data attributes, append the option name to data-
, as in data-interval=""
.
Name | -type | -default | -description | -
---|---|---|---|
interval | -number | -5000 | -The amount of time to delay between automatically cycling an item. If false, carousel will not automatically cycle. | -
pause | -string | -"hover" | -Pauses the cycling of the carousel on mouseenter and resumes the cycling of the carousel on mouseleave. | -
wrap | -boolean | -true | -Whether the carousel should cycle continuously or have hard stops. | -
Initializes the carousel with an optional options object
and starts cycling through items.
Cycles through the carousel items from left to right.
- -Stops the carousel from cycling through items.
- - -Cycles the carousel to a particular frame (0 based, similar to an array).
- -Cycles to the previous item.
- -Cycles to the next item.
- -Bootstrap's carousel class exposes two events for hooking into carousel functionality.
-Event Type | -Description | -
---|---|
slide.bs.carousel | -This event fires immediately when the slide instance method is invoked. |
-
slid.bs.carousel | -This event is fired when the carousel has completed its slide transition. | -
The subnavigation on the right is a live demo of the affix plugin.
- -Use the affix plugin via data attributes or manually with your own JavaScript. In both situations, you must provide CSS for the positioning of your content.
- -The affix plugin toggles between three classes, each representing a particular state: .affix
, .affix-top
, and .affix-bottom
. You must provide the styles for these classes yourself (independent of this plugin) to handle the actual positions.
Here's how the affix plugin works:
-.affix-top
to indicate the element is in its top-most position. At this point no CSS positioning is required..affix
replaces .affix-top
and sets position: fixed;
(provided by Bootstrap's code CSS)..affix
with .affix-bottom
. Since offsets are optional, setting one requires you to set the appropriate CSS. In this case, add position: absolute;
when necessary. The plugin uses the data attribute or JavaScript option to determine where to position the element from there.Follow the above steps to set your CSS for either of the usage options below.
- -To easily add affix behavior to any element, just add data-spy="affix"
to the element you want to spy on. Use offsets to define when to toggle the pinning of an element.
Call the affix plugin via JavaScript:
-{% highlight js %} - $('#my-affix').affix({ - offset: { - top: 100 - , bottom: function () { - return (this.bottom = $('.footer').outerHeight(true)) - } - } - }) -{% endhighlight %} - - -Options can be passed via data attributes or JavaScript. For data attributes, append the option name to data-
, as in data-offset-top="200"
.
Name | -type | -default | -description | -
---|---|---|---|
offset | -number | function | object | -10 | -Pixels to offset from screen when calculating position of scroll. If a single number is provided, the offset will be applied in both top and bottom directions. To provide a unique, bottom and top offset just provide an object offset: { top: 10 } or offset: { top: 10, bottom: 5 } . Use a function when you need to dynamically calculate an offset. |
-
Bootstrap's affix class exposes a few events for hooking into affix functionality.
-Event Type | -Description | -
---|---|
affix.bs.affix | -This event fires immediately before the element has been affixed. | -
affixed.bs.affix | -This event is fired after the element has been affixed. | -
affix-top.bs.affix | -This event fires immediately before the element has been affixed-top. | -
affixed-top.bs.affix | -This event is fired after the element has been affixed-top. | -
affix-bottom.bs.affix | -This event fires immediately before the element has been affixed-bottom. | -
affixed-bottom.bs.affix | -This event is fired after the element has been affixed-bottom. | -