Sie sind auf Seite 1von 63

CSS

Global CSS settings, fundamental HTML elements styled and


enhanced with extensible classes, and an advanced grid system.

Overview
Get the lowdown on the key pieces of Bootstrap's infrastructure, including our
approach to better, faster, stronger web development.

HTML5 doctype
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.
Copy

<!DOCTYPE html>
<html lang="en">
...
</html>

Mobile first
With Bootstrap 2, w e added optional mobile friendly styles for key aspects of the framew ork. With Bootstrap 3,
w e've rew ritten 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 m obile 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 view port m eta tag to your <head> .
<meta name="viewport" content="width=devicewidth, initialscale=1">

Copy

You can disable zooming capabilities on mobile devices by adding userscalable=no to the view port 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, w e don't recommend this on every site, so use caution!
<meta name="viewport" content="width=devicewidth, initialscale=1, maximumscale=1,
userscalable=no">

Copy

Typography and links


Bootstrap sets basic global display, typography, and link styles. Specifically, w e:
Set backgroundcolor: #fff; on the body
Use the @fontfamilybase , @fontsizebase , and @lineheightbase attributes as our typographic base
Set the global link color via @linkcolor and apply link underlines only on :hover
These styles can be found w ithin scaffolding.less .

Normalize.css
1 of 63

1 of 63

For improved cross-brow ser rendering, w e use Normalize.css, a project by Nicolas Gallagher and Jonathan
Neal.

Containers
Bootstrap requires a containing element to w rap site contents and house our grid system. You may choose one
of tw o containers to use in your projects. Note that, due to padding and more, neither container is nestable.
Use .container for a responsive fixed w idth container.
Copy

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

Use .containerfluid for a full w idth container, spanning the entire w idth of your view port.
Copy

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

Grid system
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.

Introduction
Grid systems are used for creating page layouts through a series of row s and columns that house your
content. Here's how the Bootstrap grid system w orks:
Row s must be placed w ithin a .container (fixed-w idth) or .containerfluid (full-w idth) for proper
alignment and padding.
Use row s to create horizontal groups of columns.
Content should be placed w ithin columns, and only columns may be immediate children of row s.
Predefined grid classes like .row and .colxs4 are available for quickly making grid layouts. Less
mixins can also be used for more semantic layouts.
Columns create gutters (gaps betw een column content) via padding . That padding is offset in row s for
the first and last column via negative margin on .row s.
The negative margin is w hy the examples below are outdented. It's so that content w ithin grid columns is
lined up w ith non-grid content.
Grid columns are created by specifying the number of tw elve available columns you w ish to span. For
example, three equal columns w ould use three .colxs4 .
If more than 12 columns are placed w ithin a single row , each group of extra columns w ill, as one unit,
w rap onto a new line.
Grid classes apply to devices w ith screen w idths greater than or equal to the breakpoint sizes, and
override grid classes targeted at smaller devices. Therefore, applying any .colmd class to an element
2 of 63

2 of 63

w ill not only affect its styling on medium devices but also on large devices if a .collg class is not
present.
Look to the examples for applying these principles to your code.

Media queries
We use the follow ing media queries in our Less files to create the key breakpoints in our grid system.
Copy

/* Extra small devices (phones, less than 768px) */


/* No media query since this is the default in Bootstrap */
/* Small devices (tablets, 768px and up) */
@media (minwidth: @screensmmin) { ... }
/* Medium devices (desktops, 992px and up) */
@media (minwidth: @screenmdmin) { ... }
/* Large devices (large desktops, 1200px and up) */
@media (minwidth: @screenlgmin) { ... }

We occasionally expand on these media queries to include a maxwidth to limit CSS to a narrow er set of
devices.
@media
@media
@media
@media

(maxwidth:
(minwidth:
(minwidth:
(minwidth:

@screenxsmax)
@screensmmin)
@screenmdmin)
@screenlgmin)

Copy

{ ... }
and (maxwidth: @screensmmax) { ... }
and (maxwidth: @screenmdmax) { ... }
{ ... }

Grid options
See how aspects of the Bootstrap grid system w ork across multiple devices w ith a handy table.
Extra sm all
devices Phones

Sm all devices

Medium devices

Large devices

(<768px)

Tablets (768px)

Desktops (992px)

Desktops (1200px)

Grid behavior

Horizontal at all times

Collapsed to start, horizontal above breakpoints

Container w idth

None (auto)

750px

Class prefix

.colxs

970px

.colsm

# of colum ns

12

Colum n w idth

Auto

Gutter w idth

30px (15px on each side of a column)

Nestable

Yes

Offsets

Yes

Colum n ordering

Yes

~62px

.colmd

~81px

3 of 63

1170px
.collg

~97px

3 of 63

Example: Stacked-to-horizontal
Using a single set of .colmd* 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 .
.col-md-1
.col-md-1
.col-md-1
.col-md-1
.col-md-1
.col-md-1
.col-md-1
.col-md-1
.col-md-1
.col-md-1
.col-md-1
.col-md-1

.col-md-8
.col-md-4

.col-md-4
.col-md-4
.col-md-4

.col-md-6
.col-md-6
Copy

4 of 63

4 of 63

<div class="row">
<div class="colmd1">.colmd1</div>
<div class="colmd1">.colmd1</div>
<div class="colmd1">.colmd1</div>
<div class="colmd1">.colmd1</div>
<div class="colmd1">.colmd1</div>
<div class="colmd1">.colmd1</div>
<div class="colmd1">.colmd1</div>
<div class="colmd1">.colmd1</div>
<div class="colmd1">.colmd1</div>
<div class="colmd1">.colmd1</div>
<div class="colmd1">.colmd1</div>
<div class="colmd1">.colmd1</div>
</div>
<div class="row">
<div class="colmd8">.colmd8</div>
<div class="colmd4">.colmd4</div>
</div>
<div class="row">
<div class="colmd4">.colmd4</div>
<div class="colmd4">.colmd4</div>
<div class="colmd4">.colmd4</div>
</div>
<div class="row">
<div class="colmd6">.colmd6</div>
<div class="colmd6">.colmd6</div>
</div>

Example: Fluid container


Turn any fixed-w idth grid layout into a full-w idth layout by changing your outermost .container to .container
fluid .
Copy

<div class="containerfluid">
<div class="row">
...
</div>
</div>

Example: Mobile and desktop


Don't w ant your columns to simply stack in smaller devices? Use the extra small and medium device grid
classes by adding .colxs* .colmd* to your columns. See the example below for a better idea of how it all
w orks.
.col-xs-12 .col-md-8
.col-xs-6 .col-md-4

.col-xs-6 .col-md-4

.col-xs-6 .col-md-4

.col-xs-6 .col-md-4

5 of 63

5 of 63

.col-xs-6

.col-xs-6

<! Stack the columns on mobile by making one fullwidth and the other halfwidth >
<div class="row">
<div class="colxs12 colmd8">.colxs12 .colmd8</div>
<div class="colxs6 colmd4">.colxs6 .colmd4</div>
</div>

Copy

<! Columns start at 50% wide on mobile and bump up to 33.3% wide on desktop >
<div class="row">
<div class="colxs6 colmd4">.colxs6 .colmd4</div>
<div class="colxs6 colmd4">.colxs6 .colmd4</div>
<div class="colxs6 colmd4">.colxs6 .colmd4</div>
</div>
<! Columns are always 50% wide, on mobile and desktop >
<div class="row">
<div class="colxs6">.colxs6</div>
<div class="colxs6">.colxs6</div>
</div>

Example: Mobile, tablet, desktops


Build on the previous example by creating even more dynamic and pow erful layouts w ith tablet .colsm*
classes.
.col-xs-12 .col-sm-6 .col-md-8

.col-xs-6 .col-sm-4

.col-xs-6 .col-md-4

.col-xs-6 .col-sm-4

.col-xs-6 .col-sm-4

<div class="row">
<div class="colxs12 colsm6 colmd8">.colxs12 .colsm6 .colmd8</div>
<div class="colxs6 colmd4">.colxs6 .colmd4</div>
</div>
<div class="row">
<div class="colxs6 colsm4">.colxs6 .colsm4</div>
<div class="colxs6 colsm4">.colxs6 .colsm4</div>
<! Optional: clear the XS cols if their content doesn't match in height >
<div class="clearfix visiblexsblock"></div>
<div class="colxs6 colsm4">.colxs6 .colsm4</div>
</div>

Copy

Example: Column wrapping


If more than 12 columns are placed w ithin a single row , each group of extra columns w ill, as one unit, w rap
onto a new line.
.col-xs-9
.col-xs-4
Since 9 + 4 = 13 > 12, this

.col-xs-6
Subsequent columns continue along the new line.
6 of 63

6 of 63

4-column-w ide div gets w rapped


onto a new line as one
contiguous unit.

<div class="row">
<div class="colxs9">.colxs9</div>
<div class="colxs4">.colxs4<br>Since 9 + 4 = 13 &gt; 12, this 4columnwide div gets
wrapped onto a new line as one contiguous unit.</div>
<div class="colxs6">.colxs6<br>Subsequent columns continue along the new line.</div>
</div>

Copy

Responsive column resets


With the four tiers of grids available you're bound to run into issues w here, 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.
.col-xs-6 .col-sm-3
Resize your view port
or check it out on your
phone for an example.

.col-xs-6 .col-sm-3

.col-xs-6 .col-sm-3

.col-xs-6 .col-sm-3

<div class="row">
<div class="colxs6 colsm3">.colxs6 .colsm3</div>
<div class="colxs6 colsm3">.colxs6 .colsm3</div>

Copy

<! Add the extra clearfix for only the required viewport >
<div class="clearfix visiblexsblock"></div>
<div class="colxs6 colsm3">.colxs6 .colsm3</div>
<div class="colxs6 colsm3">.colxs6 .colsm3</div>
</div>

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.
<div class="row">
<div class="colsm5 colmd6">.colsm5 .colmd6</div>
<div class="colsm5 colsmoffset2 colmd6 colmdoffset0">.colsm5 .colsmoffset2
.colmd6 .colmdoffset0</div>
</div>

Copy

<div class="row">
<div class="colsm6 colmd5 collg6">.colsm6 .colmd5 .collg6</div>
<div class="colsm6 colmd5 colmdoffset2 collg6 collgoffset0">.colsm6 .colmd5
.colmdoffset2 .collg6 .collgoffset0</div>
</div>

Offsetting columns
Move columns to the right using .colmdoffset* classes. These classes increase the left margin of a column
by * columns. For example, .colmdoffset4 moves .colmd4 over four columns.

7 of 63

7 of 63

.col-md-4
.col-md-4 .col-md-offset-4

.col-md-3 .col-md-offset-3
.col-md-3 .col-md-offset-3

.col-md-6 .col-md-offset-3

<div class="row">
<div class="colmd4">.colmd4</div>
<div class="colmd4 colmdoffset4">.colmd4
</div>
<div class="row">
<div class="colmd3 colmdoffset3">.colmd3
<div class="colmd3 colmdoffset3">.colmd3
</div>
<div class="row">
<div class="colmd6 colmdoffset3">.colmd6
</div>

Copy

.colmdoffset4</div>

.colmdoffset3</div>
.colmdoffset3</div>

.colmdoffset3</div>

Nesting columns
To nest your content w ith the default grid, add a new .row and set of .colsm* columns w ithin an existing
.colsm* column. Nested row s should include a set of columns that add up to 12 or less (it is not required that
you use all 12 available columns).
Level 1: .col-sm-9
Level 2: .col-xs-8 .col-sm-6

<div class="row">
<div class="colsm9">
Level 1: .colsm9
<div class="row">
<div class="colxs8
Level 2: .colxs8
</div>
<div class="colxs4
Level 2: .colxs4
</div>
</div>
</div>
</div>

Level 2: .col-xs-4 .col-sm-6

Copy

colsm6">
.colsm6
colsm6">
.colsm6

Column ordering
Easily change the order of our built-in grid columns w ith .colmdpush* and .colmdpull* modifier classes.
8 of 63

8 of 63

.col-md-9 .col-md-push-3
.col-md-3 .col-md-pull-9

<div class="row">
<div class="colmd9 colmdpush3">.colmd9 .colmdpush3</div>
<div class="colmd3 colmdpull9">.colmd3 .colmdpull9</div>
</div>

Copy

Less mixins and variables


In addition to prebuilt grid classes for fast layouts, Bootstrap includes Less variables and mixins for quickly
generating your ow n simple, semantic layouts.

Variables
Variables determine the number of columns, the gutter w idth, and the media query point at w hich to begin
floating columns. We use these to generate the predefined grid classes documented above, as w ell as for the
custom mixins listed below .
@gridcolumns:
@gridgutterwidth:
@gridfloatbreakpoint:

Copy

12;
30px;
768px;

Mixins
Mixins are used in conjunction w ith the grid variables to generate semantic CSS for individual grid columns.
Copy

9 of 63

9 of 63

// Creates a wrapper for a series of columns


.makerow(@gutter: @gridgutterwidth) {
// Then clear the floated columns
.clearfix();
@media (minwidth: @screensmmin) {
marginleft: (@gutter / 2);
marginright: (@gutter / 2);
}
// Negative margin nested rows out to align the content of columns
.row {
marginleft: (@gutter / 2);
marginright: (@gutter / 2);
}
}
// Generate the extra small columns
.makexscolumn(@columns; @gutter: @gridgutterwidth) {
position: relative;
// Prevent columns from collapsing when empty
minheight: 1px;
// Inner gutter via padding
paddingleft: (@gutter / 2);
paddingright: (@gutter / 2);
// Calculate width based on number of columns available
@media (minwidth: @gridfloatbreakpoint) {
float: left;
width: percentage((@columns / @gridcolumns));
}
}
// Generate the small columns
.makesmcolumn(@columns; @gutter: @gridgutterwidth) {
position: relative;
// Prevent columns from collapsing when empty
minheight: 1px;
// Inner gutter via padding
paddingleft: (@gutter / 2);
paddingright: (@gutter / 2);
// Calculate width based on number of columns available
@media (minwidth: @screensmmin) {
float: left;
width: percentage((@columns / @gridcolumns));
}
}
// Generate the small column offsets
.makesmcolumnoffset(@columns) {
@media (minwidth: @screensmmin) {
marginleft: percentage((@columns / @gridcolumns));
}
}
.makesmcolumnpush(@columns) {
@media (minwidth: @screensmmin) {
left: percentage((@columns / @gridcolumns));

10 of 63

10 of 63

Example usage
You can modify the variables to your ow n custom values, or just use the mixins w ith their default values. Here's
an example of using the default settings to create a tw o-column layout w ith a gap betw een.
.wrapper {
.makerow();
}
.contentmain {
.makelgcolumn(8);
}
.contentsecondary {
.makelgcolumn(3);
.makelgcolumnoffset(1);
}

Copy

<div class="wrapper">
<div class="contentmain">...</div>
<div class="contentsecondary">...</div>
</div>

Copy

Typography
Headings
All HTML headings, <h1> through <h6> , are available. .h1 through .h6 classes are also available, for w hen
you w ant to match the font styling of a heading but still w ant your text to be displayed inline.
EXAMPL E

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

Copy

11 of 63

11 of 63

<h1>h1.
<h2>h2.
<h3>h3.
<h4>h4.
<h5>h5.
<h6>h6.

Bootstrap
Bootstrap
Bootstrap
Bootstrap
Bootstrap
Bootstrap

heading</h1>
heading</h2>
heading</h3>
heading</h4>
heading</h5>
heading</h6>

Create lighter, secondary text in any heading w ith a generic <small> tag or the .small class.
EXAMPL E

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

<h1>h1.
<h2>h2.
<h3>h3.
<h4>h4.
<h5>h5.
<h6>h6.

Bootstrap
Bootstrap
Bootstrap
Bootstrap
Bootstrap
Bootstrap

heading
heading
heading
heading
heading
heading

<small>Secondary
<small>Secondary
<small>Secondary
<small>Secondary
<small>Secondary
<small>Secondary

text</small></h1>
text</small></h2>
text</small></h3>
text</small></h4>
text</small></h5>
text</small></h6>

Copy

Body copy
Bootstrap's global default fontsize is 14px, w ith a lineheight 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).
EXAMPL E

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.
Copy

12 of 63

12 of 63

<p>...</p>

Lead body copy


Make a paragraph stand out by adding .lead .
EXAMPL E

Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor. Duis
mollis, est non commodo luctus.
Copy

<p class="lead">...</p>

Built with Less


The typographic scale is based on tw o Less variables in variables.less: @fontsizebase and @line
heightbase . 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.

Inline text elements


Marked text
For highlighting a run of text due to its relevance in another context, use the <mark> tag.
EXAMPL E

You can use the mark tag to highlight text.


You can use the mark tag to <mark>highlight</mark> text.

Copy

Deleted text
For indicating blocks of text that have been deleted use the <del> tag.
EXAMPL E

This line of text is meant to be treated as deleted text.


<del>This line of text is meant to be treated as deleted text.</del>

Copy

Strikethrough text
For indicating blocks of text that are no longer relevant use the <s> tag.
EXAMPL E

This line of text is meant to be treated as no longer accurate.


Copy

13 of 63

13 of 63

<s>This line of text is meant to be treated as no longer accurate.</s>

Inserted text
For indicating additions to the document use the <ins> tag.
EXAMPL E

This line of text is meant to be treated as an addition to the document.


<ins>This line of text is meant to be treated as an addition to the document.</ins>

Copy

Underlined text
To underline text use the <u> tag.
EXAMPL E

This line of text w ill render as underlined


<u>This line of text will render as underlined</u>

Copy

Make use of HTML's default emphasis tags w ith lightw eight styles.

Small text
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 ow n fontsize for nested <small> elements.
You may alternatively use an inline element w ith .small in place of any <small> .
EXAMPL E
This line of text is meant to be treated as f ine print.

<small>This line of text is meant to be treated as fine print.</small>

Copy

Bold
For emphasizing a snippet of text w ith a heavier font-w eight.
EXAMPL E

The follow ing snippet of text is rendered as bold text.


Copy

<strong>rendered as bold text</strong>

Italics
For emphasizing a snippet of text w ith italics.

14 of 63

14 of 63

EXAMPL E

The follow ing snippet of text is rendered as italicized text.


Copy

<em>rendered as italicized text</em>

Alternate elements
Feel free to use <b> and <i> in HTML5. <b> is meant to highlight w ords or phrases w ithout conveying
additional importance w hile <i> is mostly for voice, technical terms, etc.

Alignment classes
Easily realign text to components w ith text alignment classes.
EXAMPL E

Left aligned text.


Center aligned text.
Right aligned text.
Justified text.
No w rap text.
<p
<p
<p
<p
<p

Copy

class="textleft">Left aligned text.</p>


class="textcenter">Center aligned text.</p>
class="textright">Right aligned text.</p>
class="textjustify">Justified text.</p>
class="textnowrap">No wrap text.</p>

Transformation classes
Transform text in components w ith text capitalization classes.
EXAMPL E

low ercased text.


UPPERCASED TEXT.
Capitalized Text.
Copy

<p class="textlowercase">Lowercased text.</p>


<p class="textuppercase">Uppercased text.</p>
<p class="textcapitalize">Capitalized text.</p>

Abbreviations
Stylized implementation of HTML's <abbr> element for abbreviations and acronyms to show the expanded
version on hover. Abbreviations w ith a title attribute have a light dotted bottom border and a help cursor on
15 of 63

15 of 63

hover, providing additional context on hover.

Basic abbreviation
For expanded text on long hover of an abbreviation, include the title attribute w ith the <abbr> element.
EXAMPL E

An abbreviation of the w ord attribute is attr.


Copy

<abbr title="attribute">attr</abbr>

Initialism
Add .initialism to an abbreviation for a slightly smaller font-size.
EXAMPL E
HTML

is the best thing since sliced bread.

<abbr title="HyperText Markup Language" class="initialism">HTML</abbr>

Copy

Addresses
Present contact information for the nearest ancestor or the entire body of w ork. Preserve formatting by ending
all lines w ith <br> .
EXAMPL E

Tw itter, Inc.
795 Folsom Ave, Suite 600
San Francisco, CA 94107
P: (123) 456-7890
Full Nam e
first.last@example.com

Copy

<address>
<strong>Twitter, Inc.</strong><br>
795 Folsom Ave, Suite 600<br>
San Francisco, CA 94107<br>
<abbr title="Phone">P:</abbr> (123) 4567890
</address>
<address>
<strong>Full Name</strong><br>
<a href="mailto:#">first.last@example.com</a>
</address>

Blockquotes
For quoting blocks of content from another source w ithin your document.
16 of 63

16 of 63

Default blockquote
Wrap <blockquote> around any HTML as the quote. For straight quotes, w e recommend a <p> .
EXAMPL E

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat a
ante.
<blockquote>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat a ante.</p>
</blockquote>

Copy

Blockquote options
Style and content changes for simple variations on a standard <blockquote> .

Naming a source
Add a <footer> for identifying the source. Wrap the name of the source w ork in <cite> .
EXAMPL E

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat a
ante.
Someone famous in Source Title

<blockquote>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat a ante.</p>
<footer>Someone famous in <cite title="Source Title">Source Title</cite></footer>
</blockquote>

Copy

Alternate displays
Add .blockquotereverse for a blockquote w ith right-aligned content.
EXAMPL E

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat a ante.
Someone famous in Source Title
Copy

<blockquote class="blockquotereverse">
...
</blockquote>

Lists
Unordered
17 of 63

17 of 63

A list of items in w hich the order does not explicitly matter.


EXAMPL E

Lorem ipsum dolor sit amet


Consectetur adipiscing elit
Integer molestie lorem at massa
Facilisis in pretium nisl aliquet
Nulla volutpat aliquam velit
Phasellus iaculis neque
Purus sodales ultricies
Vestibulum laoreet porttitor sem
Ac tristique libero volutpat at
Faucibus porta lacus fringilla vel
Aenean sit amet erat nunc
Eget porttitor lorem
Copy

<ul>
<li>...</li>
</ul>

Ordered
A list of items in w hich the order does explicitly matter.
EXAMPL E

1.
2.
3.
4.
5.
6.
7.
8.

Lorem ipsum dolor sit amet


Consectetur adipiscing elit
Integer molestie lorem at massa
Facilisis in pretium nisl aliquet
Nulla volutpat aliquam velit
Faucibus porta lacus fringilla vel
Aenean sit amet erat nunc
Eget porttitor lorem
Copy

<ol>
<li>...</li>
</ol>

Unstyled
Remove the default liststyle and left margin on list items (immediate children only). This only applies to
im m ediate children list item s, meaning you w ill need to add the class for any nested lists as w ell.
EXAMPL E

Lorem ipsum dolor sit amet


Consectetur adipiscing elit
Integer molestie lorem at massa
Facilisis in pretium nisl aliquet
Nulla volutpat aliquam velit
Phasellus iaculis neque
Purus sodales ultricies
18 of 63

18 of 63

Vestibulum laoreet porttitor sem


Ac tristique libero volutpat at
Faucibus porta lacus fringilla vel
Aenean sit amet erat nunc
Eget porttitor lorem
Copy

<ul class="listunstyled">
<li>...</li>
</ul>

Inline
Place all list items on a single line w ith display: inlineblock; and some light padding.
EXAMPL E

Lorem ipsum Phasellus iaculis Nulla volutpat


Copy

<ul class="listinline">
<li>...</li>
</ul>

Description
A list of terms w ith their associated descriptions.
EXAMPL E

Description lists
A description list is perfect for defining terms.
Euism od
Vestibulum id ligula porta felis euismod semper eget lacinia odio sem nec elit.
Donec id elit non mi porta gravida at eget metus.
Malesuada porta
Etiam porta sem malesuada magna mollis euismod.

Copy

<dl>
<dt>...</dt>
<dd>...</dd>
</dl>

Horizontal description
Make terms and descriptions in <dl> line up side-by-side. Starts off stacked like default <dl> s, but w hen the
navbar expands, so do these.
EXAMPL E

Description lists
Euism od
Malesuada porta
Felis euism od sem ...

A description list is perfect for defining terms.


Vestibulum id ligula porta felis euismod semper eget lacinia odio sem nec elit.
Donec id elit non mi porta gravida at eget metus.
Etiam porta sem malesuada magna mollis euismod.
Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut
19 of 63

19 of 63

fermentum massa justo sit amet risus.

Copy

<dl class="dlhorizontal">
<dt>...</dt>
<dd>...</dd>
</dl>

Auto-truncating
Horizontal description lists w ill truncate terms that are too long to fit in the left column w ith
textoverflow . In narrow er view ports, they w ill change to the default stacked layout.

Code
Inline
Wrap inline snippets of code w ith <code> .
EXAMPL E

For example, <section> should be w rapped as inline.


For example, <code>&lt;section&gt;</code> should be wrapped as inline.

Copy

User input
Use the <kbd> to indicate input that is typically entered via keyboard.
EXAMPL E

To sw itch directories, type cd follow ed by the name of the directory.


To edit settings, press ctrl + ,
To switch directories, type <kbd>cd</kbd> followed by the name of the directory.<br>
To edit settings, press <kbd><kbd>ctrl</kbd> + <kbd>,</kbd></kbd>

Copy

Basic block
Use <pre> for multiple lines of code. Be sure to escape any angle brackets in the code for proper rendering.
EXAMPL E

<p>Sample text here...</p>

20 of 63

20 of 63

Copy

<pre>&lt;p&gt;Sample text here...&lt;/p&gt;</pre>

You may optionally add the .prescrollable class, w hich w ill set a max-height of 350px and provide a y-axis
scrollbar.

Variables
For indicating variables use the <var> tag.
EXAMPL E

y = mx + b
Copy

<var>y</var> = <var>m</var><var>x</var> + <var>b</var>

Sample output
For indicating blocks sample output from a program use the <samp> tag.
EXAMPL E

This text is meant to be treated as sample output from a computer program.


<samp>This text is meant to be treated as sample output from a computer program.</samp>

Copy

Tables
Basic example
For basic stylinglight padding and only horizontal dividersadd the base class .table to any <table> . It may
seem super redundant, but given the w idespread use of tables for other plugins like calendars and date
pickers, w e've opted to isolate our custom table styles.
EXAMPL E

Optional table caption.


#

First Nam e

Last Nam e

Usernam e

Mark

Otto

@mdo

Jacob

Thornton

@fat

Larry

the Bird

@tw itter
Copy

21 of 63

21 of 63

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

Striped rows
Use .tablestriped to add zebra-striping to any table row w ithin the <tbody> .

Cross-browser compatibility
Striped tables are styled via the :nthchild CSS selector, w hich is not available in Internet Explorer 8.

EXAMPL E

First Nam e

Last Nam e

Usernam e

Mark

Otto

@mdo

Jacob

Thornton

@fat

Larry

the Bird

@tw itter
Copy

<table class="table tablestriped">


...
</table>

Bordered table
Add .tablebordered for borders on all sides of the table and cells.
EXAMPL E

First Nam e

Last Nam e

Usernam e

Mark

Otto

@mdo

Mark

Otto

@Tw Bootstrap

Jacob

Thornton

@fat

Larry the Bird

@tw itter
Copy

<table class="table tablebordered">


...
</table>

Hover rows
Add .tablehover to enable a hover state on table row s w ithin a <tbody> .
22 of 63

22 of 63

EXAMPL E

First Nam e

Last Nam e

Usernam e

Mark

Otto

@mdo

Jacob

Thornton

@fat

Larry the Bird

@tw itter
Copy

<table class="table tablehover">


...
</table>

Condensed table
Add .tablecondensed to make tables more compact by cutting cell padding in half.
EXAMPL E

First Nam e

Last Nam e

Usernam e

Mark

Otto

@mdo

Jacob

Thornton

@fat

Larry the Bird

@tw itter
Copy

<table class="table tablecondensed">


...
</table>

Contextual classes
Use contextual classes to color table row s 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 w arning that might need attention

.danger

Indicates a dangerous or potentially negative action

EXAMPL E

Colum n heading

Colum n heading

23 of 63

Colum n heading

23 of 63

Colum n heading

Colum n heading

Colum n heading

Column content

Column content

Column content

Column content

Column content

Column content

Column content

Column content

Column content

Column content

Column content

Column content

Column content

Column content

Column content

Column content

Column content

Column content

Column content

Column content

Column content

Column content

Column content

Column content

Column content

Column content

Column content
Copy

<! On rows >


<tr class="active">...</tr>
<tr class="success">...</tr>
<tr class="warning">...</tr>
<tr class="danger">...</tr>
<tr class="info">...</tr>
<! On cells (`td` or `th`) >
<tr>
<td class="active">...</td>
<td class="success">...</td>
<td class="warning">...</td>
<td class="danger">...</td>
<td class="info">...</td>
</tr>

Responsive tables
Create responsive tables by w rapping any .table in .tableresponsive to make them scroll horizontally on
small devices (under 768px). When view ing on anything larger than 768px w ide, you w ill not see any
difference in these tables.

Firefox and fieldsets


Firefox has some aw kw ard fieldset styling involving width that interferes w ith the responsive table.
This cannot be overriden w ithout a Firefox-specific hack that w e don't provide in Bootstrap:
Copy

@mozdocument urlprefix() {
fieldset { display: tablecell; }
}

For more information, read this Stack Overflow answ er.

24 of 63

24 of 63

EXAMPL E

Table
heading

Table
heading

Table
heading

Table
heading

Table
heading

Table
heading

Table cell

Table cell

Table cell

Table cell

Table cell

Table cell

Table cell

Table cell

Table cell

Table cell

Table cell

Table cell

Table cell

Table cell

Table cell

Table cell

Table cell

Table cell

Table
heading

Table
heading

Table
heading

Table
heading

Table
heading

Table
heading

Table cell

Table cell

Table cell

Table cell

Table cell

Table cell

Table cell

Table cell

Table cell

Table cell

Table cell

Table cell

Table cell

Table cell

Table cell

Table cell

Table cell

Table cell
Copy

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

Forms
Basic example
Individual form controls automatically receive some global styling. All textual <input> , <textarea> , and
<select> elements w ith .formcontrol are set to width: 100%; by default. Wrap labels and controls in
.formgroup for optimum spacing.
EXAMPL E

Em ail address
Enter email
Passw ord
Passw ord
File input
Browse

No file selected.

Example block-level help text here.


25 of 63

25 of 63

Check me out
Submit

<form role="form">
<div class="formgroup">
<label for="exampleInputEmail1">Email address</label>
<input type="email" class="formcontrol" id="exampleInputEmail1" placeholder="Enter email">
</div>
<div class="formgroup">
<label for="exampleInputPassword1">Password</label>
<input type="password" class="formcontrol" id="exampleInputPassword1"
placeholder="Password">
</div>
<div class="formgroup">
<label for="exampleInputFile">File input</label>
<input type="file" id="exampleInputFile">
<p class="helpblock">Example blocklevel help text here.</p>
</div>
<div class="checkbox">
<label>
<input type="checkbox"> Check me out
</label>
</div>
<button type="submit" class="btn btndefault">Submit</button>
</form>

Copy

Don't mix form groups with input groups


Do not mix form groups directly w ith input groups. Instead, nest the input group inside of the form group.

Inline form
Add .forminline to your <form> for left-aligned and inline-block controls. This only applies to form s
w ithin view ports that are at least 768px w ide.

Requires custom widths


Inputs and selects have width: 100%; applied by default in Bootstrap. Within inline forms, w e reset that
to width: auto; so multiple controls can reside on the same line. Depending on your layout, additional
custom w idths may be required.

Always add labels


Screen readers w ill have trouble w ith your forms if you don't include a label for every input. For these
inline forms, you can hide the labels using the .sronly class.

26 of 63

26 of 63

EXAMPL E

Enter email

Passw ord

Enter email

Remember me Sign in
<form class="forminline" role="form">
<div class="formgroup">
<label class="sronly" for="exampleInputEmail2">Email address</label>
<input type="email" class="formcontrol" id="exampleInputEmail2" placeholder="Enter email">
</div>
<div class="formgroup">
<div class="inputgroup">
<div class="inputgroupaddon">@</div>
<input class="formcontrol" type="email" placeholder="Enter email">
</div>
</div>
<div class="formgroup">
<label class="sronly" for="exampleInputPassword2">Password</label>
<input type="password" class="formcontrol" id="exampleInputPassword2"
placeholder="Password">
</div>
<div class="checkbox">
<label>
<input type="checkbox"> Remember me
</label>
</div>
<button type="submit" class="btn btndefault">Sign in</button>
</form>

Copy

Horizontal form
Use Bootstrap's predefined grid classes to align labels and groups of form controls in a horizontal layout by
adding .formhorizontal to the form. Doing so changes .formgroup s to behave as grid row s, so no need for
.row .
EXAMPL E

Em ail
Passw ord

Email
Passw ord
Remember me
Sign in

Copy

27 of 63

27 of 63

<form class="formhorizontal" role="form">


<div class="formgroup">
<label for="inputEmail3" class="colsm2 controllabel">Email</label>
<div class="colsm10">
<input type="email" class="formcontrol" id="inputEmail3" placeholder="Email">
</div>
</div>
<div class="formgroup">
<label for="inputPassword3" class="colsm2 controllabel">Password</label>
<div class="colsm10">
<input type="password" class="formcontrol" id="inputPassword3" placeholder="Password">
</div>
</div>
<div class="formgroup">
<div class="colsmoffset2 colsm10">
<div class="checkbox">
<label>
<input type="checkbox"> Remember me
</label>
</div>
</div>
</div>
<div class="formgroup">
<div class="colsmoffset2 colsm10">
<button type="submit" class="btn btndefault">Sign in</button>
</div>
</div>
</form>

Supported controls
Examples of standard form controls supported in an example form layout.

Inputs
Most common form control, text-based input fields. Includes support for all HTML5 types: text , password ,
datetime , datetimelocal , date , month , time , week , number , email , url , search , tel , and color .

Type declaration required


Inputs w ill only be fully styled if their type is properly declared.

EXAMPL E

Text input

<input type="text" class="formcontrol" placeholder="Text input">

Copy

Input groups
To add integrated text or buttons before and/or after any text-based <input> , check out the input group
28 of 63

28 of 63

component.

Textarea
Form control w hich supports multiple lines of text. Change rows attribute as necessary.
EXAMPL E

<textarea class="formcontrol" rows="3"></textarea>

Copy

Checkboxes and radios


Checkboxes are for selecting one or several options in a list, w hile radios are for selecting one option from
many.
A checkbox or radio w ith the disabled attribute w ill be styled appropriately. To have the <label> for the
checkbox or radio also display a "not-allow ed" cursor w hen the user hovers over the label, add the .disabled
class to your .radio , .radioinline , .checkbox , .checkboxinline , or <fieldset> .

Default (stacked)
EXAMPL E

Option one is this and thatbe sure to include w hy it's great


Option tw o is disabled

Option one is this and thatbe sure to include w hy it's great


Option tw o can be something else and selecting it w ill deselect option one
Option three is disabled
Copy

29 of 63

29 of 63

<div class="checkbox">
<label>
<input type="checkbox" value="">
Option one is this and that&mdash;be sure to include why it's great
</label>
</div>
<div class="checkbox disabled">
<label>
<input type="checkbox" value="" disabled>
Option two is disabled
</label>
</div>
<div class="radio">
<label>
<input type="radio" name="optionsRadios" id="optionsRadios1" value="option1" checked>
Option one is this and that&mdash;be sure to include why it's great
</label>
</div>
<div class="radio">
<label>
<input type="radio" name="optionsRadios" id="optionsRadios2" value="option2">
Option two can be something else and selecting it will deselect option one
</label>
</div>
<div class="radio disabled">
<label>
<input type="radio" name="optionsRadios" id="optionsRadios3" value="option3" disabled>
Option three is disabled
</label>
</div>

Inline checkboxes and radios


Use the .checkboxinline or .radioinline classes on a series of checkboxes or radios for controls that
appear on the same line.
EXAMPL E

3
Copy

30 of 63

30 of 63

<label class="checkboxinline">
<input type="checkbox" id="inlineCheckbox1" value="option1"> 1
</label>
<label class="checkboxinline">
<input type="checkbox" id="inlineCheckbox2" value="option2"> 2
</label>
<label class="checkboxinline">
<input type="checkbox" id="inlineCheckbox3" value="option3"> 3
</label>
<label class="radioinline">
<input type="radio" name="inlineRadioOptions" id="inlineRadio1" value="option1"> 1
</label>
<label class="radioinline">
<input type="radio" name="inlineRadioOptions" id="inlineRadio2" value="option2"> 2
</label>
<label class="radioinline">
<input type="radio" name="inlineRadioOptions" id="inlineRadio3" value="option3"> 3
</label>

Checkboxes and radios without labels


Should you have no text w ithin the <label> , the input is positioned as you'd expect. Currently only w orks
on non-inline checkboxes and radios.
EXAMPL E

<div class="checkbox">
<label>
<input type="checkbox" id="blankCheckbox" value="option1">
</label>
</div>
<div class="radio">
<label>
<input type="radio" name="blankRadio" id="blankRadio1" value="option1">
</label>
</div>

Copy

Selects
Use the default option, or add multiple to show multiple options at once.
EXAMPL E

31 of 63

31 of 63

1
2
3
4
5
Copy

<select class="formcontrol">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
</select>
<select multiple class="formcontrol">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
</select>

Static control
When you need to place plain text next to a form label w ithin a form, use the .formcontrolstatic class on a
<p> .
EXAMPL E

Em ail
Passw ord

email@example.com
Passw ord

<form class="formhorizontal" role="form">


<div class="formgroup">
<label class="colsm2 controllabel">Email</label>
<div class="colsm10">
<p class="formcontrolstatic">email@example.com</p>
</div>
</div>
<div class="formgroup">
<label for="inputPassword" class="colsm2 controllabel">Password</label>
<div class="colsm10">
<input type="password" class="formcontrol" id="inputPassword" placeholder="Password">
</div>
</div>
</form>

Copy

EXAMPL E

email@example.com Passw ord

Confirm identity
Copy

32 of 63

32 of 63

<form class="forminline" role="form">


<div class="formgroup">
<label class="sronly">Email</label>
<p class="formcontrolstatic">email@example.com</p>
</div>
<div class="formgroup">
<label for="inputPassword2" class="sronly">Password</label>
<input type="password" class="formcontrol" id="inputPassword2" placeholder="Password">
</div>
<button type="submit" class="btn btndefault">Confirm identity</button>
</form>

Input focus
We remove the default outline styles on some form controls and apply a boxshadow in its place for :focus .
EXAMPL E

Demonstrative focus state

Demo :focus state


The above example input uses custom styles in our documentation to demonstrate the :focus state on a
.formcontrol .

Disabled inputs
Add the disabled boolean attribute on an input to prevent user input and trigger a slightly different look.
EXAMPL E

Disabled input here

<input class="formcontrol" id="disabledInput" type="text" placeholder="Disabled input here..."


disabled>

Copy

Disabled fieldsets
Add the disabled attribute to a <fieldset> to disable all the controls w ithin the <fieldset> at once.

Caveat about link functionality of <a>


Our styles use pointerevents: 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.

Cross-browser compatibility
33 of 63

33 of 63

While Bootstrap w ill apply these styles in all brow sers, Internet Explorer 11 and below don't fully support
the disabled attribute on a <fieldset> . Use custom JavaScript to disable the fieldset in these brow sers.

EXAMPL E

Disabled input
Disabled input
Disabled select m enu
Disabled select
Can't check this

<form role="form">
<fieldset disabled>
<div class="formgroup">
<label for="disabledTextInput">Disabled input</label>
<input type="text" id="disabledTextInput" class="formcontrol" placeholder="Disabled
input">
</div>
<div class="formgroup">
<label for="disabledSelect">Disabled select menu</label>
<select id="disabledSelect" class="formcontrol">
<option>Disabled select</option>
</select>
</div>
<div class="checkbox">
<label>
<input type="checkbox"> Can't check this
</label>
</div>
<button type="submit" class="btn btnprimary">Submit</button>
</fieldset>
</form>

Copy

Readonly inputs
Add the readonly boolean attribute on an input to prevent user input and style the input as disabled.
EXAMPL E

Readonly input here

<input class="formcontrol" type="text" placeholder="Readonly input here" readonly>

Copy

Validation states
Bootstrap includes validation styles for error, w arning, and success states on form controls. To use, add
34 of 63

34 of 63

, .haserror , or .hassuccess to the parent element. Any .controllabel , .formcontrol , and


.helpblock w ithin that element w ill receive the validation styles.
.haswarning

EXAMPL E

Input w ith success

Input w ith w arning

Input w ith error

Checkbox w ith success


Checkbox w ith w arning
Checkbox w ith error
Copy

35 of 63

35 of 63

<div class="formgroup hassuccess">


<label class="controllabel" for="inputSuccess1">Input with success</label>
<input type="text" class="formcontrol" id="inputSuccess1">
</div>
<div class="formgroup haswarning">
<label class="controllabel" for="inputWarning1">Input with warning</label>
<input type="text" class="formcontrol" id="inputWarning1">
</div>
<div class="formgroup haserror">
<label class="controllabel" for="inputError1">Input with error</label>
<input type="text" class="formcontrol" id="inputError1">
</div>
<div class="hassuccess">
<div class="checkbox">
<label>
<input type="checkbox" id="checkboxSuccess" value="option1">
Checkbox with success
</label>
</div>
</div>
<div class="haswarning">
<div class="checkbox">
<label>
<input type="checkbox" id="checkboxWarning" value="option1">
Checkbox with warning
</label>
</div>
</div>
<div class="haserror">
<div class="checkbox">
<label>
<input type="checkbox" id="checkboxError" value="option1">
Checkbox with error
</label>
</div>
</div>

With optional icons


You can also add optional feedback icons w ith the addition of .hasfeedback and the right icon.
Feedback icons only w ork w ith textual <input class="formcontrol"> elem ents.

Icons, labels, and input groups


Manual positioning of feedback icons is required for inputs w ithout a label and for input groups w ith an
add-on on the right. You are strongly encouraged to provide labels for all inputs for accessibility
reasons. If you w ish to prevent labels from being displayed, hide them w ith the sronly class. If you
must do w ithout labels, adjust the top value of the feedback icon. For input groups, adjust the right
value to an appropriate pixel value depending on the w idth of your addon.

EXAMPL E

Input w ith success


36 of 63

36 of 63

Input w ith w arning

Input w ith error

<div class="formgroup hassuccess hasfeedback">


<label class="controllabel" for="inputSuccess2">Input with success</label>
<input type="text" class="formcontrol" id="inputSuccess2">
<span class="glyphicon glyphiconok formcontrolfeedback"></span>
</div>
<div class="formgroup haswarning hasfeedback">
<label class="controllabel" for="inputWarning2">Input with warning</label>
<input type="text" class="formcontrol" id="inputWarning2">
<span class="glyphicon glyphiconwarningsign formcontrolfeedback"></span>
</div>
<div class="formgroup haserror hasfeedback">
<label class="controllabel" for="inputError2">Input with error</label>
<input type="text" class="formcontrol" id="inputError2">
<span class="glyphicon glyphiconremove formcontrolfeedback"></span>
</div>

Copy

Optional icons in horizontal and inline forms


EXAMPL E

Input w ith success

<form class="formhorizontal" role="form">


<div class="formgroup hassuccess hasfeedback">
<label class="controllabel colsm3" for="inputSuccess3">Input with success</label>
<div class="colsm9">
<input type="text" class="formcontrol" id="inputSuccess3">
<span class="glyphicon glyphiconok formcontrolfeedback"></span>
</div>
</div>
</form>

Copy

EXAMPL E

Input w ith success

Copy

37 of 63

37 of 63

<form class="forminline" role="form">


<div class="formgroup hassuccess hasfeedback">
<label class="controllabel" for="inputSuccess4">Input with success</label>
<input type="text" class="formcontrol" id="inputSuccess4">
<span class="glyphicon glyphiconok formcontrolfeedback"></span>
</div>
</form>

Optional icons with hidden .sronly labels


For form controls w ith no visible label, add the .sronly class on the label. Bootstrap w ill automatically adjust
the position of the icon once it's been added.
EXAMPL E

<div class="formgroup hassuccess hasfeedback">


<label class="controllabel sronly" for="inputSuccess5">Hidden label</label>
<input type="text" class="formcontrol" id="inputSuccess5">
<span class="glyphicon glyphiconok formcontrolfeedback"></span>
</div>

Copy

Control sizing
Set heights using classes like .inputlg , and set w idths using grid column classes like .collg* .

Height sizing
Create taller or shorter form controls that match button sizes.
EXAMPL E

.input-lg
Default input
.input-sm

.input-lg
Default select
.input-sm

Copy

38 of 63

38 of 63

<input class="formcontrol inputlg" type="text" placeholder=".inputlg">


<input class="formcontrol" type="text" placeholder="Default input">
<input class="formcontrol inputsm" type="text" placeholder=".inputsm">
<select class="formcontrol inputlg">...</select>
<select class="formcontrol">...</select>
<select class="formcontrol inputsm">...</select>

Horizontal form group sizes


Quickly size labels and form controls w ithin .formhorizontal by adding .formgrouplg or .formgroupsm .
EXAMPL E

Large label
Sm all label

Large input
Small input

<form class="formhorizontal" role="form">


<div class="formgroup formgrouplg">
<label class="colsm2 controllabel" for="formGroupInputLarge">Large label</label>
<div class="colsm10">
<input class="formcontrol" type="text" id="formGroupInputLarge" placeholder="Large
input">
</div>
</div>
<div class="formgroup formgroupsm">
<label class="colsm2 controllabel" for="formGroupInputSmall">Small label</label>
<div class="colsm10">
<input class="formcontrol" type="text" id="formGroupInputSmall" placeholder="Small
input">
</div>
</div>
</form>

Copy

Column sizing
Wrap inputs in grid columns, or any custom parent element, to easily enforce desired w idths.
EXAMPL E

.col-xs-2

.col-xs-3

.col-xs-4
Copy

39 of 63

39 of 63

<div class="row">
<div class="colxs2">
<input type="text" class="formcontrol" placeholder=".colxs2">
</div>
<div class="colxs3">
<input type="text" class="formcontrol" placeholder=".colxs3">
</div>
<div class="colxs4">
<input type="text" class="formcontrol" placeholder=".colxs4">
</div>
</div>

Help text
Block level help text for form controls.
EXAMPL E

A block of help text that breaks onto a new line and may extend beyond one line.

<span class="helpblock">A block of help text that breaks onto a new line and may extend beyond
one line.</span>

Copy

Buttons
Options
Use any of the available button classes to quickly create a styled button.
EXAMPL E

Default Primary Success Info Warning Danger Link

Copy

40 of 63

40 of 63

<! Standard button >


<button type="button" class="btn btndefault">Default</button>
<! Provides extra visual weight and identifies the primary action in a set of buttons >
<button type="button" class="btn btnprimary">Primary</button>
<! Indicates a successful or positive action >
<button type="button" class="btn btnsuccess">Success</button>
<! Contextual button for informational alert messages >
<button type="button" class="btn btninfo">Info</button>
<! Indicates caution should be taken with this action >
<button type="button" class="btn btnwarning">Warning</button>
<! Indicates a dangerous or potentially negative action >
<button type="button" class="btn btndanger">Danger</button>
<! Deemphasize a button by making it look like a link while maintaining button behavior >
<button type="button" class="btn btnlink">Link</button>

Sizes
Fancy larger or smaller buttons? Add .btnlg , .btnsm , or .btnxs for additional sizes.
EXAMPL E

Large button

Large button

Default button Default button


Small button

Small button

Extra small button

<p>
<button
<button
</p>
<p>
<button
<button
</p>
<p>
<button
<button
</p>
<p>
<button
<button
</p>

Extra small button


Copy

type="button" class="btn btnprimary btnlg">Large button</button>


type="button" class="btn btndefault btnlg">Large button</button>

type="button" class="btn btnprimary">Default button</button>


type="button" class="btn btndefault">Default button</button>

type="button" class="btn btnprimary btnsm">Small button</button>


type="button" class="btn btndefault btnsm">Small button</button>

type="button" class="btn btnprimary btnxs">Extra small button</button>


type="button" class="btn btndefault btnxs">Extra small button</button>

Create block level buttonsthose that span the full w idth of a parent by adding .btnblock .
41 of 63

41 of 63

EXAMPL E

Block level button


Block level button

<button type="button" class="btn btnprimary btnlg btnblock">Block level button</button>


<button type="button" class="btn btndefault btnlg btnblock">Block level button</button>

Copy

Active state
Buttons w ill appear pressed (w ith a darker background, darker border, and inset shadow ) w hen active. For
<button> elements, this is done via :active . For <a> elements, it's done w ith .active . How ever, you may use
.active on <button> s should you need to replicate the active state programmatically.

Button element
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 .
EXAMPL E

Primary button

Button

<button type="button" class="btn btnprimary btnlg active">Primary button</button>


<button type="button" class="btn btndefault btnlg active">Button</button>

Copy

Anchor element
Add the .active class to <a> buttons.
EXAMPL E

Primary link

Link

<a href="#" class="btn btnprimary btnlg active" role="button">Primary link</a>


<a href="#" class="btn btndefault btnlg active" role="button">Link</a>

Copy

Disabled state
Make buttons look unclickable by fading them back w ith opacity .

Button element
42 of 63

42 of 63

Add the disabled attribute to <button> buttons.


EXAMPL E

<button type="button" class="btn btnlg btnprimary" disabled="disabled">Primary button</button>


<button type="button" class="btn btndefault btnlg" disabled="disabled">Button</button>

Copy

Cross-browser compatibility
If you add the disabled attribute to a <button> , Internet Explorer 9 and below w ill render text gray w ith
a nasty text-shadow that w e cannot fix.

Anchor element
Add the .disabled class to <a> buttons.
EXAMPL E

<a href="#" class="btn btnprimary btnlg disabled" role="button">Primary link</a>


<a href="#" class="btn btndefault btnlg disabled" role="button">Link</a>

Copy

We use .disabled as a utility class here, similar to the common .active class, so no prefix is required.

Link functionality caveat


This class uses pointerevents: 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.

Context-specific usage
While button classes can be used on <a> and <button> elements, only <button> elements are
supported w ithin our nav and navbar components.

Button tags
Use the button classes on an <a> , <button> , or <input> element.

43 of 63

43 of 63

EXAMPL E

Link Button Input Submit

<a class="btn btndefault" href="#" role="button">Link</a>


<button class="btn btndefault" type="submit">Button</button>
<input class="btn btndefault" type="button" value="Input">
<input class="btn btndefault" type="submit" value="Submit">

Copy

Cross-browser rendering
As a best practice, w e highly recom m end using the <button> elem ent w henever possible to
ensure matching cross-brow ser rendering.
Among other things, there's a bug in Firefox <30 that prevents us from setting the lineheight of
<input> -based buttons, causing them to not exactly match the height of other buttons on Firefox.

Images
Responsive images
Images in Bootstrap 3 can be made responsive-friendly via the addition of the .imgresponsive class. This
applies maxwidth: 100%; and height: auto; to the image so that it scales nicely to the parent element.

SVG images and IE 8-10


In Internet Explorer 8-10, SVG images w ith .imgresponsive are disproportionately sized. To fix this, add
width: 100% \9; w here necessary. Bootstrap doesn't apply this automatically as it causes complications
to other image formats.

<img src="..." class="imgresponsive" alt="Responsive image">

Copy

Image shapes
Add classes to an <img> element to easily style images in any project.

Cross-browser compatibility
Keep in mind that Internet Explorer 8 lacks support for rounded corners.

44 of 63

44 of 63

EXAMPL E

Copy

<img src="..." alt="..." class="imgrounded">


<img src="..." alt="..." class="imgcircle">
<img src="..." alt="..." class="imgthumbnail">

Helper classes
Contextual colors
Convey meaning through color w ith a handful of emphasis utility classes. These may also be applied to links and
w ill darken on hover just like our default link styles.
EXAMPL E

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.
<p
<p
<p
<p
<p
<p

Copy

class="textmuted">...</p>
class="textprimary">...</p>
class="textsuccess">...</p>
class="textinfo">...</p>
class="textwarning">...</p>
class="textdanger">...</p>

Dealing with specificity


Sometimes emphasis classes cannot be applied due to the specificity of another selector. In most cases,
a sufficient w orkaround is to w rap your text in a <span> w ith the class.

Contextual backgrounds
45 of 63

45 of 63

Similar to the contextual text color classes, easily set the background of an element to any contextual class.
Anchor components w ill darken on hover, just like the text classes.
EXAMPL E

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.

<p
<p
<p
<p
<p

Copy

class="bgprimary">...</p>
class="bgsuccess">...</p>
class="bginfo">...</p>
class="bgwarning">...</p>
class="bgdanger">...</p>

Dealing with specificity


Sometimes contextual background classes cannot be applied due to the specificity of another selector. In
some cases, a sufficient w orkaround is to w rap your element's content in a <div> w ith the class.

Close icon
Use the generic close icon for dismissing content like modals and alerts.
EXAMPL E

<button type="button" class="close"><span ariahidden="true">&times;</span><span class="sr


only">Close</span></button>

Copy

Carets
Use carets to indicate dropdow n functionality and direction. Note that the default caret w ill reverse automatically
in dropup menus.
EXAMPL E

Copy

46 of 63

46 of 63

<span class="caret"></span>

Quick floats
Float an element to the left or right w ith a class. !important is included to avoid specificity issues. Classes can
also be used as mixins.
<div class="pullleft">...</div>
<div class="pullright">...</div>

Copy

// Classes
.pullleft {
float: left !important;
}
.pullright {
float: right !important;
}

Copy

// Usage as mixins
.element {
.pullleft();
}
.anotherelement {
.pullright();
}

Not for use in navbars


To align components in navbars w ith utility classes, use .navbarleft or .navbarright instead. See the
navbar docs for details.

Center content blocks


Set an element to display: block and center via margin . Available as a mixin and class.
<div class="centerblock">...</div>

Copy

// Classes
.centerblock {
display: block;
marginleft: auto;
marginright: auto;
}

Copy

// Usage as mixins
.element {
.centerblock();
}

Clearfix
Easily clear float s by adding .clearfix to the parent elem ent. Utilizes the micro clearfix as popularized by
47 of 63

47 of 63

Nicolas Gallagher. Can also be used as a mixin.


<! Usage as a class >
<div class="clearfix">...</div>

Copy

// Mixin itself
.clearfix() {
&:before,
&:after {
content: " ";
display: table;
}
&:after {
clear: both;
}
}

Copy

// Usage as a Mixin
.element {
.clearfix();
}

Showing and hiding content


Force an element to be show n or hidden (including for screen readers) w ith 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.
is available, but it does not alw ays affect screen readers and is deprecated as of v3.0.1. Use .hidden
or .sronly instead.
.hide

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.
Copy

<div class="show">...</div>
<div class="hidden">...</div>

Copy

48 of 63

48 of 63

// Classes
.show {
display: block !important;
}
.hidden {
display: none !important;
visibility: hidden !important;
}
.invisible {
visibility: hidden;
}
// Usage as mixins
.element {
.show();
}
.anotherelement {
.hidden();
}

Screen reader and keyboard navigation content


Hide an element to all devices except screen readers w ith .sronly . Combine .sronly w ith .sronly
focusable to show the element again w hen it's focused (e.g. by a keyboard-only user). Necessary for
follow ing accessibility best practices. Can also be used as mixins.
<a class="sronly sronlyfocusable" href="#content">Skip to main content</a>

Copy

// Usage as a Mixin
.skipnavigation {
.sronly();
.sronlyfocusable();
}

Copy

Image replacement
Utilize the .texthide class or mixin to help replace an element's text content w ith a background image.
<h1 class="texthide">Custom heading</h1>

Copy

// Usage as a Mixin
.heading {
.texthide();
}

Copy

Responsive utilities
For faster mobile-friendly development, use these utility classes for showing
49 of 63

49 of 63

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.

Available classes
Use a single or combination of the available classes for toggling content across view port breakpoints.
Extra sm all devices

Sm all devices

Medium devices

Large devices

Phones (<768px)

Tablets (768px)

Desktops (992px)

Desktops (1200px)

.visiblexs*

Visible

Hidden

Hidden

Hidden

.visiblesm*

Hidden

Visible

Hidden

Hidden

.visiblemd*

Hidden

Hidden

Visible

Hidden

.visiblelg*

Hidden

Hidden

Hidden

Visible

.hiddenxs

Hidden

Visible

Visible

Visible

.hiddensm

Visible

Hidden

Visible

Visible

.hiddenmd

Visible

Visible

Hidden

Visible

.hiddenlg

Visible

Visible

Visible

Hidden

As of v3.2.0, 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*inlineblock

display: inlineblock;

So, for extra small ( xs ) screens for example, the available .visible** classes are: .visiblexsblock ,
.visiblexsinline , and .visiblexsinlineblock .
The classes .visiblexs , .visiblesm , .visiblemd , and .visiblelg also exist, but are deprecated as of
v3.2.0. They are approximately equivalent to .visible*block , except w ith additional special cases for toggling
<table> -related elements.

Print classes
Similar to the regular responsive classes, use these for toggling content for print.
Classes

Brow ser

50 of 63

Print

50 of 63

Classes

Brow ser

.visibleprintblock

Print

Hidden

Visible

Visible

Hidden

.visibleprintinline
.visibleprintinlineblock
.hiddenprint

The class .visibleprint also exists but is deprecated as of v3.2.0. It is approximately equivalent to
.visibleprintblock , except w ith additional special cases for <table> -related elements.

Test cases
Resize your brow ser or load on different devices to test the responsive utility classes.

Visible on...
Green checkmarks indicate the element is visible in your current view port.
Extra sm all

Visible on sm all

Medium

Large

Visible on x-sm all and sm all

Medium and large

Extra sm all and m edium

Visible on sm all and large

Extra sm all and large

Visible on sm all and m edium

Hidden on...
Here, green checkmarks also indicate the element is hidden in your current view port.
Extra sm all

Hidden on sm all

Medium

Large

Hidden on x-sm all and sm all

Medium and large

Extra sm all and m edium

Hidden on sm all and large

Extra sm all and large

Hidden on sm all and m edium

Using Less
51 of 63

51 of 63

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 w ithin the Grid system section.

Compiling Bootstrap
Bootstrap can be used in at least tw o w ays: w ith the compiled CSS or w ith the source Less files. To compile
the Less files, consult the Getting Started section for how to setup your development environment to run the
necessary commands.
Third party compilation tools may w ork w ith Bootstrap, but they are not supported by our core team.

Variables
Variables are used throughout the entire project as a w ay to centralize and share commonly used values like
colors, spacing, or font stacks. For a complete breakdow n, please see the Customizer.

Colors
Easily make use of tw o color schemes: grayscale and semantic. Grayscale colors provide quick access to
commonly used shades of black w hile semantic include various colors assigned to meaningful contextual
values.
EXAMPL E

@graydarker:
@graydark:
@gray:
@graylight:
@graylighter:

lighten(#000,
lighten(#000,
lighten(#000,
lighten(#000,
lighten(#000,

13.5%);
20%);
33.5%);
46.7%);
93.5%);

//
//
//
//
//

Copy

#222
#333
#555
#777
#eee

EXAMPL E

Copy

52 of 63

52 of 63

@brandprimary:
@brandsuccess:
@brandinfo:
@brandwarning:
@branddanger:

#428bca;
#5cb85c;
#5bc0de;
#f0ad4e;
#d9534f;

Use any of these color variables as they are or reassign them to more meaningful variables for your project.
Copy

// Use asis
.masthead {
backgroundcolor: @brandprimary;
}
// Reassigned variables in Less
@alertmessagebackground: @brandinfo;
.alert {
backgroundcolor: @alertmessagebackground;
}

Scaffolding
A handful of variables for quickly customizing key elements of your site's skeleton.
Copy

// Scaffolding
@bodybg:
#fff;
@textcolor: @black50;

Links
Easily style your links w ith the right color w ith only one value.
Copy

// Variables
@linkcolor:
@brandprimary;
@linkhovercolor: darken(@linkcolor, 15%);
// Usage
a {
color: @linkcolor;
textdecoration: none;
&:hover {
color: @linkhovercolor;
textdecoration: underline;
}
}

Note that the @linkhovercolor uses a function, another aw esome tool from Less, to automagically create the
right hover color. You can use darken , lighten , saturate , and desaturate .

Typography
Easily set your type face, text size, leading, and more w ith a few quick variables. Bootstrap makes use of these
as w ell to provide easy typographic mixins.
Copy

53 of 63

53 of 63

@fontfamilysansserif:
@fontfamilyserif:
@fontfamilymonospace:
@fontfamilybase:

"Helvetica Neue", Helvetica, Arial, sansserif;


Georgia, "Times New Roman", Times, serif;
Menlo, Monaco, Consolas, "Courier New", monospace;
@fontfamilysansserif;

@fontsizebase:
@fontsizelarge:
@fontsizesmall:

14px;
ceil((@fontsizebase * 1.25)); // ~18px
ceil((@fontsizebase * 0.85)); // ~12px

@fontsizeh1:
@fontsizeh2:
@fontsizeh3:
@fontsizeh4:
@fontsizeh5:
@fontsizeh6:

floor((@fontsizebase * 2.6)); // ~36px


floor((@fontsizebase * 2.15)); // ~30px
ceil((@fontsizebase * 1.7)); // ~24px
ceil((@fontsizebase * 1.25)); // ~18px
@fontsizebase;
ceil((@fontsizebase * 0.85)); // ~12px

@lineheightbase:
@lineheightcomputed:

1.428571429; // 20/14
floor((@fontsizebase * @lineheightbase)); // ~20px

@headingsfontfamily:
@headingsfontweight:
@headingslineheight:
@headingscolor:

inherit;
500;
1.1;
inherit;

Icons
Tw o quick variables for customizing the location and filename of your icons.
@iconfontpath:
@iconfontname:

"../fonts/";
"glyphiconshalflingsregular";

Copy

Components
Components throughout Bootstrap make use of some default variables for setting common values. Here are the
most commonly used.
Copy

54 of 63

54 of 63

@paddingbasevertical:
@paddingbasehorizontal:

6px;
12px;

@paddinglargevertical:
@paddinglargehorizontal:

10px;
16px;

@paddingsmallvertical:
@paddingsmallhorizontal:

5px;
10px;

@paddingxsvertical:
@paddingxshorizontal:

1px;
5px;

@lineheightlarge:
@lineheightsmall:

1.33;
1.5;

@borderradiusbase:
@borderradiuslarge:
@borderradiussmall:

4px;
6px;
3px;

@componentactivecolor:
@componentactivebg:

#fff;
@brandprimary;

@caretwidthbase:
@caretwidthlarge:

4px;
5px;

Vendor mixins
Vendor mixins are mixins to help support multiple brow sers by including all relevant vendor prefixes in your
compiled CSS.

Box-sizing
Reset your components' box model w ith a single mixin. For context, see this helpful article from Mozilla.
The mixin is deprecated as of v3.2.0, w ith the introduction of autoprefixer. To preserve backw ardscompatibility, Bootstrap w ill continue to use the mixin internally until Bootstrap v4.
.boxsizing(@boxmodel) {
webkitboxsizing: @boxmodel; // Safari <= 5
mozboxsizing: @boxmodel; // Firefox <= 19
boxsizing: @boxmodel;
}

Copy

Rounded corners
Today all modern brow sers support the non-prefixed borderradius property. As such, there is no .border
radius() mixin, but Bootstrap does include shortcuts for quickly rounding tw o corners on a particular side of an
object.
Copy

55 of 63

55 of 63

.bordertopradius(@radius) {
bordertoprightradius: @radius;
bordertopleftradius: @radius;
}
.borderrightradius(@radius) {
borderbottomrightradius: @radius;
bordertoprightradius: @radius;
}
.borderbottomradius(@radius) {
borderbottomrightradius: @radius;
borderbottomleftradius: @radius;
}
.borderleftradius(@radius) {
borderbottomleftradius: @radius;
bordertopleftradius: @radius;
}

Box (Drop) shadows


If your target audience is using the latest and greatest brow sers and devices, be sure to just use the
boxshadow property on its ow n. 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 backw ards-compatibility, Bootstrap w ill continue to use the
mixin internally until Bootstrap v4.
Be sure to use rgba() colors in your box shadow s so they blend as seamlessly as possible w ith backgrounds.
.boxshadow(@shadow: 0 1px 3px rgba(0,0,0,.25)) {
webkitboxshadow: @shadow; // iOS <4.3 & Android <4.1
boxshadow: @shadow;
}

Copy

Transitions
Multiple mixins for flexibility. Set all transition information w ith one, or specify a separate delay and duration as
needed.
The mixins are deprecated as of v3.2.0, w ith the introduction of autoprefixer. To preserve backw ardscompatibility, Bootstrap w ill continue to use the mixins internally until Bootstrap v4.
Copy

56 of 63

56 of 63

.transition(@transition) {
webkittransition: @transition;
transition: @transition;
}
.transitionproperty(@transitionproperty) {
webkittransitionproperty: @transitionproperty;
transitionproperty: @transitionproperty;
}
.transitiondelay(@transitiondelay) {
webkittransitiondelay: @transitiondelay;
transitiondelay: @transitiondelay;
}
.transitionduration(@transitionduration) {
webkittransitionduration: @transitionduration;
transitionduration: @transitionduration;
}
.transitiontimingfunction(@timingfunction) {
webkittransitiontimingfunction: @timingfunction;
transitiontimingfunction: @timingfunction;
}
.transitiontransform(@transition) {
webkittransition: webkittransform @transition;
moztransition: moztransform @transition;
otransition: otransform @transition;
transition: transform @transition;
}

Transformations
Rotate, scale, translate (move), or skew any object.
The mixins are deprecated as of v3.2.0, w ith the introduction of autoprefixer. To preserve backw ardscompatibility, Bootstrap w ill continue to use the mixins internally until Bootstrap v4.
Copy

57 of 63

57 of 63

.rotate(@degrees) {
webkittransform: rotate(@degrees);
mstransform: rotate(@degrees); // IE9 only
transform: rotate(@degrees);
}
.scale(@ratio; @ratioy...) {
webkittransform: scale(@ratio, @ratioy);
mstransform: scale(@ratio, @ratioy); // IE9 only
transform: scale(@ratio, @ratioy);
}
.translate(@x; @y) {
webkittransform: translate(@x, @y);
mstransform: translate(@x, @y); // IE9 only
transform: translate(@x, @y);
}
.skew(@x; @y) {
webkittransform: skew(@x, @y);
mstransform: skewX(@x) skewY(@y); // See https://github.com/twbs/bootstrap/issues/4885;
IE9+
transform: skew(@x, @y);
}
.translate3d(@x; @y; @z) {
webkittransform: translate3d(@x, @y, @z);
transform: translate3d(@x, @y, @z);
}
.rotateX(@degrees) {
webkittransform: rotateX(@degrees);
mstransform: rotateX(@degrees); // IE9 only
transform: rotateX(@degrees);
}
.rotateY(@degrees) {
webkittransform: rotateY(@degrees);
mstransform: rotateY(@degrees); // IE9 only
transform: rotateY(@degrees);
}
.perspective(@perspective) {
webkitperspective: @perspective;
mozperspective: @perspective;
perspective: @perspective;
}
.perspectiveorigin(@perspective) {
webkitperspectiveorigin: @perspective;
mozperspectiveorigin: @perspective;
perspectiveorigin: @perspective;
}
.transformorigin(@origin) {
webkittransformorigin: @origin;
moztransformorigin: @origin;
mstransformorigin: @origin; // IE9 only
transformorigin: @origin;
}

Animations
A single mixin for using all of CSS3's animation properties in one declaration and other mixins for individual
properties.
58 of 63

58 of 63

The mixins are deprecated as of v3.2.0, w ith the introduction of autoprefixer. To preserve backw ardscompatibility, Bootstrap w ill continue to use the mixins internally until Bootstrap v4.
.animation(@animation) {
webkitanimation: @animation;
animation: @animation;
}
.animationname(@name) {
webkitanimationname: @name;
animationname: @name;
}
.animationduration(@duration) {
webkitanimationduration: @duration;
animationduration: @duration;
}
.animationtimingfunction(@timingfunction) {
webkitanimationtimingfunction: @timingfunction;
animationtimingfunction: @timingfunction;
}
.animationdelay(@delay) {
webkitanimationdelay: @delay;
animationdelay: @delay;
}
.animationiterationcount(@iterationcount) {
webkitanimationiterationcount: @iterationcount;
animationiterationcount: @iterationcount;
}
.animationdirection(@direction) {
webkitanimationdirection: @direction;
animationdirection: @direction;
}

Copy

Opacity
Set the opacity for all brow sers and provide a filter fallback for IE8.
Copy

.opacity(@opacity) {
opacity: @opacity;
// IE8 filter
@opacityie: (@opacity * 100);
filter: ~"alpha(opacity=@{opacityie})";
}

Placeholder text
Provide context for form controls w ithin each field.
.placeholder(@color: @inputcolorplaceholder) {
&::mozplaceholder
{ color: @color; } // Firefox
&:msinputplaceholder
{ color: @color; } // Internet Explorer 10+
&::webkitinputplaceholder { color: @color; } // Safari and Chrome
}

Copy

Columns
Generate columns via CSS w ithin a single element.
59 of 63

59 of 63

.contentcolumns(@width; @count; @gap) {


webkitcolumnwidth: @width;
mozcolumnwidth: @width;
columnwidth: @width;
webkitcolumncount: @count;
mozcolumncount: @count;
columncount: @count;
webkitcolumngap: @gap;
mozcolumngap: @gap;
columngap: @gap;
}

Gradients
Easily turn any tw o 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.
Copy

#gradient > .vertical(#333; #000);


#gradient > .horizontal(#333; #000);
#gradient > .radial(#333; #000);

You can also specify the angle of a standard tw o-color, linear gradient:
Copy

#gradient > .directional(#333; #000; 45deg);

If you need a barber-stripe style gradient, that's easy, too. Just specify a single color and w e'll overlay a
translucent w hite stripe.
Copy

#gradient > .striped(#333; 45deg);

Up the ante and use three colors instead. Set the first color, the second color, the second color's color stop (a
percentage value like 25%), and the third color w ith these mixins:
#gradient > .verticalthreecolors(#777; #333; 25%; #000);
#gradient > .horizontalthreecolors(#777; #333; 25%; #000);

Copy

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 .resetfilter() mixin alongside backgroundimage: none; .

Utility mixins
Utility mixins are mixins that combine otherw ise unrelated CSS properties to achieve a specific goal or task.

Clearfix
Forget adding class="clearfix" to any element and instead add the .clearfix() mixin w here appropriate.
Uses the micro clearfix from Nicolas Gallager.
Copy

60 of 63

60 of 63

// Mixin
.clearfix() {
&:before,
&:after {
content: " ";
display: table;
}
&:after {
clear: both;
}
}
// Usage
.container {
.clearfix();
}

Horizontal centering
Quickly center any element w ithin its parent. Requires width or maxwidth to be set.
Copy

// Mixin
.centerblock() {
display: block;
marginleft: auto;
marginright: auto;
}
// Usage
.container {
width: 940px;
.centerblock();
}

Sizing helpers
Specify the dimensions of an object more easily.
Copy

// Mixins
.size(@width; @height) {
width: @width;
height: @height;
}
.square(@size) {
.size(@size; @size);
}
// Usage
.image { .size(400px; 300px); }
.avatar { .square(48px); }

Resizable textareas
Easily configure the resize options for any textarea, or any other element. Defaults to normal brow ser behavior
( both ).
61 of 63

61 of 63

.resizable(@direction: both) {
// Options: horizontal, vertical, both
resize: @direction;
// Safari fix
overflow: auto;
}

Truncating text
Easily truncate text w ith an ellipsis w ith a single mixin. Requires elem ent to be block or inlineblock
level.
Copy

// Mixin
.textoverflow() {
overflow: hidden;
textoverflow: ellipsis;
whitespace: nowrap;
}
// Usage
.branchname {
display: inlineblock;
maxwidth: 200px;
.textoverflow();
}

Retina images
Specify tw o image paths and the @1x image dimensions, and Bootstrap w ill provide an @2x media query. If
you have m any im ages to serve, consider w riting your retina im age CSS m anually in a single
m edia query.
.imgretina(@file1x; @file2x; @width1x; @height1x) {
backgroundimage: url("@{file1x}");
@media
only screen and (webkitmindevicepixelratio:
only screen and ( minmozdevicepixelratio:
only screen and (
omindevicepixelratio:
only screen and (
mindevicepixelratio:
only screen and (
minresolution:
only screen and (
minresolution:
backgroundimage: url("@{file2x}");
backgroundsize: @width1x @height1x;
}

Copy

2),
2),
2/1),
2),
192dpi),
2dppx) {

}
// Usage
.jumbotron {
.imgretina("/img/bg1x.png", "/img/bg2x.png", 100px, 100px);
}

62 of 63

62 of 63

Using Sass
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.

What's included
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 w ith 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.

Installation
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 w ith Rails, Compass, and standard Sass projects.

Bootstrap for Sass

63 of 63

63 of 63

Das könnte Ihnen auch gefallen