1 de 65
http://getbootstrap.com/css/
CSS
Global CSS settings, fundamental HTML elements styled and
enhanced with extensible classes, and an advanced grid system.
(http://www.launchbit.com
/taz/9533-5702-111/)
Host Unlimited
Domains Unlimited
disk space and transfer
for one low price.
(http://www.launchbit.com
/taz/9533-5702-111/)
ads via Carbon
(http://carbonads.com)
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.
<!DOCTYPE html>
<html lang="en">
...
</html>
Copy
Mobile first
With Bootstrap 2, w e added optional mobile f riendly styles f or key aspects of the f ramew ork. With Bootstrap 3,
09-Dec-14 12:40 PM
CSS Bootstrap
2 de 65
http://getbootstrap.com/css/
w e've rew ritten the project to be mobile f riendly f rom the start. Instead of adding on optional mobile styles,
they're baked right into the core. In f act, Boots trap is m obile firs t. Mobile f irst styles can be f ound throughout
the entire library instead of in separate f iles.
To ensure proper rendering and touch zooming, add the vie w port m e ta tag to your <head> .
<meta name="viewport" content="width=device-width, initial-scale=1">
Copy
You can disable zooming capabilities on mobile devices by adding user-scalable=no to the view port meta tag.
This disables zooming, meaning users are only able to scroll, and results in your site f eeling 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=device-width, initial-scale=1, maximum-scale=1,
user-scalable=no">
Copy
Normalize.css
For improved cross-brow ser rendering, w e use Normalize.css (http://necolas.github.io/normalize.css/), a
project by Nicolas Gallagher (https://tw itter.com/necolas) and Jonathan Neal (https://tw itter.com/jon_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 f or a responsive f ixed w idth container.
<div class="container">
...
</div>
Copy
Use .container-fluid f or a f ull w idth container, spanning the entire w idth of your view port.
<div class="container-fluid">
...
</div>
Copy
Grid system
Bootstrap includes a responsive, mobile first fluid grid system that
09-Dec-14 12:40 PM
CSS Bootstrap
3 de 65
http://getbootstrap.com/css/
Introduction
Grid systems are used f or 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 (f ixed-w idth) or .container-fluid (f ull-w idth) f or 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.
Predef ined grid classes like .row and .col-xs-4 are available f or quickly making grid layouts. Less
mixins can also be used f or more semantic layouts.
Columns create gutters (gaps betw een column content) via padding . That padding is off set in row s f or
the f irst 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 specif ying the number of tw elve available columns you w ish to span. For
example, three equal columns w ould use three .col-xs-4 .
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. Theref ore, applying any .col-md- class to an element
w ill not only aff ect its styling on medium devices but also on large devices if a .col-lg- class is not
present.
Look to the examples f or applying these principles to your code.
Media queries
We use the f ollow ing media queries in our Less f iles to create the key breakpoints in our grid system.
/* Extra small devices (phones, less than 768px) */
/* No media query since this is the default in Bootstrap */
Copy
We occasionally expand on these media queries to include a max-width to limit CSS to a narrow er set of
devices.
@media
@media
@media
@media
(max-width:
(min-width:
(min-width:
(min-width:
@screen-xs-max)
@screen-sm-min)
@screen-md-min)
@screen-lg-min)
{ ... }
and (max-width: @screen-sm-max) { ... }
and (max-width: @screen-md-max) { ... }
{ ... }
Copy
09-Dec-14 12:40 PM
CSS Bootstrap
4 de 65
http://getbootstrap.com/css/
Grid options
See how aspects of the Bootstrap grid system w ork across multiple devices w ith a handy table.
Extra s m all
de vice s Phones
Sm all de vice s
M e dium de vice s
Large de vice s
(<768px)
Tablets (768px)
Desktops (992px)
Desktops (1200px)
Grid be havior
Containe r w idth
None (auto)
750px
.col-xs-
.col-sm-
# of colum ns
12
Colum n w idth
Auto
Gutte r w idth
Ne s table
Yes
Offs e ts
Yes
Yes
~62px
970px
.col-md-
~81px
1170px
.col-lg-
~97px
Example: Stacked-to-horizontal
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) bef ore 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
09-Dec-14 12:40 PM
CSS Bootstrap
5 de 65
http://getbootstrap.com/css/
.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
<div class="row">
<div class="col-md-1">.col-md-1</div>
<div class="col-md-1">.col-md-1</div>
<div class="col-md-1">.col-md-1</div>
<div class="col-md-1">.col-md-1</div>
<div class="col-md-1">.col-md-1</div>
<div class="col-md-1">.col-md-1</div>
<div class="col-md-1">.col-md-1</div>
<div class="col-md-1">.col-md-1</div>
<div class="col-md-1">.col-md-1</div>
<div class="col-md-1">.col-md-1</div>
<div class="col-md-1">.col-md-1</div>
<div class="col-md-1">.col-md-1</div>
</div>
<div class="row">
<div class="col-md-8">.col-md-8</div>
<div class="col-md-4">.col-md-4</div>
</div>
<div class="row">
<div class="col-md-4">.col-md-4</div>
<div class="col-md-4">.col-md-4</div>
<div class="col-md-4">.col-md-4</div>
</div>
<div class="row">
<div class="col-md-6">.col-md-6</div>
<div class="col-md-6">.col-md-6</div>
</div>
Copy
09-Dec-14 12:40 PM
CSS Bootstrap
6 de 65
http://getbootstrap.com/css/
<div class="container-fluid">
<div class="row">
...
</div>
</div>
.col-xs-6 .col-md-4
.col-xs-6 .col-md-4
.col-xs-6 .col-md-4
.col-xs-6
.col-xs-6
<!-- Stack the columns on mobile by making one full-width and the other half-width -->
<div class="row">
<div class="col-xs-12 col-md-8">.col-xs-12 .col-md-8</div>
<div class="col-xs-6 col-md-4">.col-xs-6 .col-md-4</div>
</div>
Copy
<!-- Columns start at 50% wide on mobile and bump up to 33.3% wide on desktop -->
<div class="row">
<div class="col-xs-6 col-md-4">.col-xs-6 .col-md-4</div>
<div class="col-xs-6 col-md-4">.col-xs-6 .col-md-4</div>
<div class="col-xs-6 col-md-4">.col-xs-6 .col-md-4</div>
</div>
<!-- Columns are always 50% wide, on mobile and desktop -->
<div class="row">
<div class="col-xs-6">.col-xs-6</div>
<div class="col-xs-6">.col-xs-6</div>
</div>
.col-xs-6 .col-sm-4
.col-xs-6 .col-md-4
.col-xs-6 .col-sm-4
.col-xs-6 .col-sm-4
09-Dec-14 12:40 PM
CSS Bootstrap
7 de 65
http://getbootstrap.com/css/
<div class="row">
<div class="col-xs-12 col-sm-6 col-md-8">.col-xs-12 .col-sm-6 .col-md-8</div>
<div class="col-xs-6 col-md-4">.col-xs-6 .col-md-4</div>
</div>
<div class="row">
<div class="col-xs-6 col-sm-4">.col-xs-6 .col-sm-4</div>
<div class="col-xs-6 col-sm-4">.col-xs-6 .col-sm-4</div>
<!-- Optional: clear the XS cols if their content doesn't match in height -->
<div class="clearfix visible-xs-block"></div>
<div class="col-xs-6 col-sm-4">.col-xs-6 .col-sm-4</div>
</div>
.col-xs-6
Subsequent columns continue along the new line.
<div class="row">
<div class="col-xs-9">.col-xs-9</div>
<div class="col-xs-4">.col-xs-4<br>Since 9 + 4 = 13 > 12, this 4-column-wide div gets
wrapped onto a new line as one contiguous unit.</div>
<div class="col-xs-6">.col-xs-6<br>Subsequent columns continue along the new line.</div>
</div>
Copy
.col-xs-6 .col-sm-3
.col-xs-6 .col-sm-3
.col-xs-6 .col-sm-3
Copy
09-Dec-14 12:40 PM
CSS Bootstrap
8 de 65
http://getbootstrap.com/css/
<div class="row">
<div class="col-xs-6 col-sm-3">.col-xs-6 .col-sm-3</div>
<div class="col-xs-6 col-sm-3">.col-xs-6 .col-sm-3</div>
<!-- Add the extra clearfix for only the required viewport -->
<div class="clearfix visible-xs-block"></div>
<div class="col-xs-6 col-sm-3">.col-xs-6 .col-sm-3</div>
<div class="col-xs-6 col-sm-3">.col-xs-6 .col-sm-3</div>
</div>
In addition to column clearing at responsive breakpoints, you may need to re s e t offs e ts , pus he s , or pulls .
See this in action in the grid example (../examples/grid/).
<div class="row">
<div class="col-sm-5 col-md-6">.col-sm-5 .col-md-6</div>
<div class="col-sm-5 col-sm-offset-2 col-md-6 col-md-offset-0">.col-sm-5 .col-sm-offset-2
.col-md-6 .col-md-offset-0</div>
</div>
Copy
<div class="row">
<div class="col-sm-6 col-md-5 col-lg-6">.col-sm-6 .col-md-5 .col-lg-6</div>
<div class="col-sm-6 col-md-5 col-md-offset-2 col-lg-6 col-lg-offset-0">.col-sm-6 .col-md-5
.col-md-offset-2 .col-lg-6 .col-lg-offset-0</div>
</div>
Offsetting columns
Move columns to the right using .col-md-offset-* classes. These classes increase the lef t margin of a column
by * columns. For example, .col-md-offset-4 moves .col-md-4 over f our columns.
.col-md-4
.col-md-4 .col-md-off set-4
Copy
09-Dec-14 12:40 PM
CSS Bootstrap
9 de 65
http://getbootstrap.com/css/
<div class="row">
<div class="col-md-4">.col-md-4</div>
<div class="col-md-4 col-md-offset-4">.col-md-4
</div>
<div class="row">
<div class="col-md-3 col-md-offset-3">.col-md-3
<div class="col-md-3 col-md-offset-3">.col-md-3
</div>
<div class="row">
<div class="col-md-6 col-md-offset-3">.col-md-6
</div>
.col-md-offset-4</div>
.col-md-offset-3</div>
.col-md-offset-3</div>
.col-md-offset-3</div>
Nesting columns
To nest your content w ith the def ault grid, add a new .row and set of .col-sm-* columns w ithin an existing
.col-sm-* 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="col-sm-9">
Level 1: .col-sm-9
<div class="row">
<div class="col-xs-8
Level 2: .col-xs-8
</div>
<div class="col-xs-4
Level 2: .col-xs-4
</div>
</div>
</div>
</div>
Copy
col-sm-6">
.col-sm-6
col-sm-6">
.col-sm-6
Column ordering
Easily change the order of our built-in grid columns w ith .col-md-push-* and .col-md-pull-* modif ier classes.
.col-md-9 .col-md-push-3
.col-md-3 .col-md-pull-9
<div class="row">
<div class="col-md-9 col-md-push-3">.col-md-9 .col-md-push-3</div>
<div class="col-md-3 col-md-pull-9">.col-md-3 .col-md-pull-9</div>
</div>
Copy
09-Dec-14 12:40 PM
CSS Bootstrap
10 de 65
http://getbootstrap.com/css/
In addition to prebuilt grid classes f or f ast layouts, Bootstrap includes Less variables and mixins f or 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
f loating columns. We use these to generate the predef ined grid classes documented above, as w ell as f or the
custom mixins listed below .
@grid-columns:
@grid-gutter-width:
@grid-float-breakpoint:
12;
30px;
768px;
Copy
Mixins
Mixins are used in conjunction w ith the grid variables to generate semantic CSS f or individual grid columns.
Copy
09-Dec-14 12:40 PM
CSS Bootstrap
11 de 65
http://getbootstrap.com/css/
09-Dec-14 12:40 PM
CSS Bootstrap
12 de 65
http://getbootstrap.com/css/
Example usage
You can modif y the variables to your ow n custom values, or just use the mixins w ith their def ault values. Here's
an example of using the def ault settings to create a tw o-column layout w ith a gap betw een.
.wrapper {
.make-row();
}
.content-main {
.make-lg-column(8);
}
.content-secondary {
.make-lg-column(3);
.make-lg-column-offset(1);
}
Copy
<div class="wrapper">
<div class="content-main">...</div>
<div class="content-secondary">...</div>
</div>
Copy
Typography
Headings
All HTML headings, <h1> through <h6> , are available. .h1 through .h6 classes are also available, f or w hen
you w ant to match the f ont styling of a heading but still w ant your text to be displayed inline.
EXAMPL E
Semibold 36px
Semibold 30px
Semibold 24px
Semibold 18px
Semibold 14px
Semibold 12px
Copy
09-Dec-14 12:40 PM
CSS Bootstrap
13 de 65
http://getbootstrap.com/css/
<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>h1.
<h2>h2.
<h3>h3.
<h4>h4.
<h5>h5.
<h6>h6.
Bootstrap
Bootstrap
Bootstrap
Bootstrap
Bootstrap
Bootstrap
Secondary text
Secondary text
Secondary text
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 def ault font-size is 14px, w ith 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
def ault).
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 f ringilla. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia
odio sem nec elit. Donec ullamcorper nulla non metus auctor f ringilla.
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
09-Dec-14 12:40 PM
CSS Bootstrap
14 de 65
http://getbootstrap.com/css/
<p>...</p>
Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor.
Duis mollis, est non commodo luctus.
<p class="lead">...</p>
Copy
Copy
Deleted text
For indicating blocks of text that have been deleted use the <del> tag.
EXAMPL E
Copy
Strikethrough text
For indicating blocks of text that are no longer relevant use the <s> tag.
EXAMPL E
09-Dec-14 12:40 PM
CSS Bootstrap
15 de 65
http://getbootstrap.com/css/
Inserted text
For indicating additions to the document use the <ins> tag.
EXAMPL E
Copy
Underlined text
To underline text use the <u> tag.
EXAMPL E
Copy
Make use of HTML's def ault 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 font-size f or 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.
Copy
Bold
For emphasizing a snippet of text w ith a heavier f ont-w eight.
EXAMPL E
Copy
Italics
For emphasizing a snippet of text w ith italics.
09-Dec-14 12:40 PM
CSS Bootstrap
16 de 65
http://getbootstrap.com/css/
EXAMPL E
Alternate elements
Feel f ree 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 f or voice, technical terms, etc.
Alignment classes
Easily realign text to components w ith text alignment classes.
EXAMPL E
Copy
Transformation classes
Transf orm text in components w ith text capitalization classes.
EXAMPL E
Copy
Abbreviations
Stylized implementation of HTML's <abbr> element f or 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
09-Dec-14 12:40 PM
CSS Bootstrap
17 de 65
http://getbootstrap.com/css/
Basic abbreviation
For expanded text on long hover of an abbreviation, include the title attribute w ith the <abbr> element.
EXAMPL E
Copy
Initialism
Add .initialism to an abbreviation f or a slightly smaller f ont-size.
EXAMPL E
HTML (HYPERTEXT MARKUP LANGUAGE) is the best thing since sliced bread.
Copy
Addresses
Present contact inf ormation f or the nearest ancestor or the entire body of w ork. Preserve f ormatting by ending
all lines w ith <br> .
EXAMPL E
Tw itte r, Inc.
795 Folsom Ave, Suite 600
San Francisco, CA 94107
P: (Phone) (123) 456-7890
Full Nam e
f irst.last@example.com (mailto:#)
<address>
<strong>Twitter, Inc.</strong><br>
795 Folsom Ave, Suite 600<br>
San Francisco, CA 94107<br>
<abbr title="Phone">P:</abbr> (123) 456-7890
</address>
Copy
<address>
<strong>Full Name</strong><br>
<a href="mailto:#">first.last@example.com</a>
</address>
Blockquotes
For quoting blocks of content f rom another source w ithin your document.
09-Dec-14 12:40 PM
CSS Bootstrap
18 de 65
http://getbootstrap.com/css/
Default blockquote
Wrap <blockquote> around any HTML (HyperText Markup Language) 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 f or simple variations on a standard <blockquote> .
Naming a source
Add a <footer> f or identif ying 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 f amous 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 .blockquote-reverse f or a blockquote w ith right-aligned content.
EXAMPL E
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat a ante.
Someone f amous in Source Title
<blockquote class="blockquote-reverse">
...
</blockquote>
Copy
Lists
09-Dec-14 12:40 PM
CSS Bootstrap
19 de 65
http://getbootstrap.com/css/
Unordered
A list of items in w hich the order does not explicitly matter.
EXAMPL E
Copy
Ordered
A list of items in w hich the order does explicitly matter.
EXAMPL E
Copy
Unstyled
Remove the def ault list-style and lef t margin on list items (immediate children only). This only applie s to
im m e diate childre n lis t ite m s , meaning you w ill need to add the class f or any nested lists as w ell.
EXAMPL E
09-Dec-14 12:40 PM
CSS Bootstrap
20 de 65
http://getbootstrap.com/css/
<ul class="list-unstyled">
<li>...</li>
</ul>
Inline
Place all list items on a single line w ith display: inline-block; and some light padding.
EXAMPL E
Nulla volutpat
Copy
<ul class="list-inline">
<li>...</li>
</ul>
Description
A list of terms w ith their associated descriptions.
EXAMPL E
De s cription lis ts
A description list is perf ect f or def ining terms.
Euis m od
Vestibulum id ligula porta f elis euismod semper eget lacinia odio sem nec elit.
Donec id elit non mi porta gravida at eget metus.
M ale s uada porta
Etiam porta sem malesuada magna mollis euismod.
<dl>
<dt>...</dt>
<dd>...</dd>
</dl>
Copy
Horizontal description
Make terms and descriptions in <dl> line up side-by-side. Starts off stacked like def ault <dl> s, but w hen the
navbar expands, so do these.
EXAMPL E
De s cription lis ts
Euis m od
09-Dec-14 12:40 PM
CSS Bootstrap
21 de 65
http://getbootstrap.com/css/
<dl class="dl-horizontal">
<dt>...</dt>
<dd>...</dd>
</dl>
Copy
Auto-truncating
Horizontal description lists w ill truncate terms that are too long to f it in the lef t column w ith
text-overflow . In narrow er view ports, they w ill change to the def ault stacked layout.
Code
Inline
Wrap inline snippets of code w ith <code> .
EXAMPL E
Copy
User input
Use the <kbd> to indicate input that is typically entered via keyboard.
EXAMPL E
Copy
Basic block
Use <pre> f or multiple lines of code. Be sure to escape any angle brackets in the code f or proper rendering.
09-Dec-14 12:40 PM
CSS Bootstrap
22 de 65
http://getbootstrap.com/css/
EXAMPL E
Copy
You may optionally add the .pre-scrollable 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
Sample output
For indicating blocks sample output f rom a program use the <samp> tag.
EXAMPL E
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 f or other plugins like calendars and date
pickers, w e've opted to isolate our custom table styles.
EXAMPL E
Firs t Nam e
Las t Nam e
Us e rnam e
Mark
Otto
@mdo
09-Dec-14 12:40 PM
CSS Bootstrap
23 de 65
http://getbootstrap.com/css/
Firs t Nam e
Las t Nam e
Us e rnam e
Jacob
Thornton
@f at
Larry
the Bird
@tw itter
Copy
<table class="table">
...
</table>
Striped rows
Use .table-striped to add zebra-striping to any table row w ithin the <tbody> .
Cross-browser compatibility
Striped tables are styled via the :nth-child CSS selector, w hich is not available in Internet Explorer 8.
EXAMPL E
Firs t Nam e
Las t Nam e
Us e rnam e
Mark
Otto
@mdo
Jacob
Thornton
@f at
Larry
the Bird
@tw itter
Copy
Bordered table
Add .table-bordered f or borders on all sides of the table and cells.
EXAMPL E
Firs t Nam e
Las t Nam e
Us e rnam e
Mark
Otto
@mdo
Mark
Otto
@Tw Bootstrap
Jacob
Thornton
@f at
@tw itter
Copy
09-Dec-14 12:40 PM
CSS Bootstrap
24 de 65
http://getbootstrap.com/css/
Hover rows
Add .table-hover to enable a hover state on table row s w ithin a <tbody> .
EXAMPL E
Firs t Nam e
Las t Nam e
Us e rnam e
Mark
Otto
@mdo
Jacob
Thornton
@f at
@tw itter
Copy
Condensed table
Add .table-condensed to make tables more compact by cutting cell padding in half .
EXAMPL E
Firs t Nam e
Las t Nam e
Us e rnam e
Mark
Otto
@mdo
Jacob
Thornton
@f at
@tw itter
Copy
Contextual classes
Use contextual classes to color table row s or individual cells.
Clas s
De s cription
.active
.success
.info
09-Dec-14 12:40 PM
CSS Bootstrap
25 de 65
http://getbootstrap.com/css/
Clas s
De s cription
.warning
.danger
EXAMPL E
Colum n he ading
Colum n he ading
Colum n he ading
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
09-Dec-14 12:40 PM
CSS Bootstrap
26 de 65
http://getbootstrap.com/css/
Responsive tables
Create responsive tables by w rapping any .table in .table-responsive 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
diff erence in these tables.
@-moz-document url-prefix() {
fieldset { display: table-cell; }
}
For more inf ormation, read this Stack Overf low answ er (http://stackoverf low .com/questions/17408815
/f ieldset-resizes-w rong-appears-to-have-unremovable-min-w idth-min-content/17863685#17863685).
EXAMPL E
Table
he ading
Table
he ading
Table
he ading
Table
he ading
Table
he ading
Table
he ading
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
he ading
Table
he ading
Table
he ading
Table
he ading
Table
he ading
Table
he ading
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
<div class="table-responsive">
<table class="table">
...
</table>
</div>
Copy
Forms
09-Dec-14 12:40 PM
CSS Bootstrap
27 de 65
http://getbootstrap.com/css/
Basic example
Individual f orm controls automatically receive some global styling. All textual <input> , <textarea> , and
<select> elements w ith .form-control are set to width: 100%; by def ault. Wrap labels and controls in
.form-group f or optimum spacing.
EXAMPL E
Em ail addre s s
Enter email
Pas s w ord
Passw ord
File input
Examinar
<form role="form">
<div class="form-group">
<label for="exampleInputEmail1">Email address</label>
<input type="email" class="form-control" id="exampleInputEmail1" placeholder="Enter email">
</div>
<div class="form-group">
<label for="exampleInputPassword1">Password</label>
<input type="password" class="form-control" id="exampleInputPassword1"
placeholder="Password">
</div>
<div class="form-group">
<label for="exampleInputFile">File input</label>
<input type="file" id="exampleInputFile">
<p class="help-block">Example block-level help text here.</p>
</div>
<div class="checkbox">
<label>
<input type="checkbox"> Check me out
</label>
</div>
<button type="submit" class="btn btn-default">Submit</button>
</form>
Copy
09-Dec-14 12:40 PM
CSS Bootstrap
28 de 65
http://getbootstrap.com/css/
Inline form
Add .form-inline to your <form> f or lef t-aligned and inline-block controls. This only applie s to form s
w ithin vie w ports that are at le as t 768px w ide .
EXAMPL E
Enter email
Remember me
Enter email
Passw ord
Sign in
Copy
Horizontal form
Use Bootstrap's predef ined grid classes to align labels and groups of f orm controls in a horizontal layout by
adding .form-horizontal to the f orm. Doing so changes .form-group s to behave as grid row s, so no need f or
09-Dec-14 12:40 PM
CSS Bootstrap
29 de 65
http://getbootstrap.com/css/
.row .
EXAMPL E
Em ail
Pas s w ord
Email
Passw ord
Remember me
Sign in
Copy
Supported controls
Examples of standard f orm controls supported in an example f orm layout.
Inputs
Most common f orm control, text-based input f ields. Includes support f or all HTML5 types: text , password ,
datetime , datetime-local , date , month , time , week , number , email , url , search , tel , and color .
09-Dec-14 12:40 PM
CSS Bootstrap
30 de 65
http://getbootstrap.com/css/
EXAMPL E
Text input
Copy
Input groups
To add integrated text or buttons bef ore and/or af ter any text-based <input> , check out the input group
component (../components/#input-groups).
Textarea
Form control w hich supports multiple lines of text. Change rows attribute as necessary.
EXAMPL E
Textarea
Copy
Default (stacked)
EXAMPL E
Copy
09-Dec-14 12:40 PM
CSS Bootstrap
31 de 65
http://getbootstrap.com/css/
<div class="checkbox">
<label>
<input type="checkbox" value="">
Option one is this and that—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—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>
3
Copy
09-Dec-14 12:40 PM
CSS Bootstrap
32 de 65
http://getbootstrap.com/css/
<label class="checkbox-inline">
<input type="checkbox" id="inlineCheckbox1" value="option1"> 1
</label>
<label class="checkbox-inline">
<input type="checkbox" id="inlineCheckbox2" value="option2"> 2
</label>
<label class="checkbox-inline">
<input type="checkbox" id="inlineCheckbox3" value="option3"> 3
</label>
<label class="radio-inline">
<input type="radio" name="inlineRadioOptions" id="inlineRadio1" value="option1"> 1
</label>
<label class="radio-inline">
<input type="radio" name="inlineRadioOptions" id="inlineRadio2" value="option2"> 2
</label>
<label class="radio-inline">
<input type="radio" name="inlineRadioOptions" id="inlineRadio3" value="option3"> 3
</label>
<div class="checkbox">
<label>
<input type="checkbox" id="blankCheckbox" value="option1" aria-label="...">
</label>
</div>
<div class="radio">
<label>
<input type="radio" name="blankRadio" id="blankRadio1" value="option1" aria-label="...">
</label>
</div>
Copy
Selects
Use the def ault option, or add multiple to show multiple options at once.
EXAMPL E
09-Dec-14 12:40 PM
CSS Bootstrap
33 de 65
http://getbootstrap.com/css/
1
2
3
4
5
Copy
<select class="form-control">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
</select>
<select multiple class="form-control">
<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 f orm label w ithin a f orm, use the .form-control-static class on a
<p> .
EXAMPL E
Em ail
email@example.com
Pas s w ord
Passw ord
Copy
EXAMPL E
email@example.com
Passw ord
09-Dec-14 12:40 PM
CSS Bootstrap
34 de 65
http://getbootstrap.com/css/
Focus state
We remove the def ault outline styles on some f orm controls and apply a box-shadow in its place f or :focus .
EXAMPL E
Disabled state
Add the disabled boolean attribute on an input to prevent user input and trigger a slightly diff erent look.
EXAMPL E
Copy
Disabled fieldsets
Add the disabled attribute to a <fieldset> to disable all the controls w ithin the <fieldset> at once.
Cross-browser compatibility
09-Dec-14 12:40 PM
CSS Bootstrap
35 de 65
http://getbootstrap.com/css/
While Bootstrap w ill apply these styles in all brow sers, Internet Explorer 11 and below don't f ully support
the disabled attribute on a <fieldset> . Use custom JavaScript to disable the f ieldset in these brow sers.
EXAMPL E
<form role="form">
<fieldset disabled>
<div class="form-group">
<label for="disabledTextInput">Disabled input</label>
<input type="text" id="disabledTextInput" class="form-control" placeholder="Disabled
input">
</div>
<div class="form-group">
<label for="disabledSelect">Disabled select menu</label>
<select id="disabledSelect" class="form-control">
<option>Disabled select</option>
</select>
</div>
<div class="checkbox">
<label>
<input type="checkbox"> Can't check this
</label>
</div>
<button type="submit" class="btn btn-primary">Submit</button>
</fieldset>
</form>
Copy
Readonly state
Add the readonly boolean attribute on an input to prevent user input and style the input as disabled.
EXAMPL E
Copy
Validation states
Bootstrap includes validation styles f or error, w arning, and success states on f orm controls. To use, add
09-Dec-14 12:40 PM
CSS Bootstrap
36 de 65
http://getbootstrap.com/css/
.has-warning , .has-error , or .has-success to the parent element. Any .control-label , .form-control , and
.help-block w ithin that element w ill receive the validation styles.
EXAMPL E
Copy
09-Dec-14 12:40 PM
CSS Bootstrap
37 de 65
http://getbootstrap.com/css/
09-Dec-14 12:40 PM
CSS Bootstrap
38 de 65
http://getbootstrap.com/css/
icon, additional hidden text should be included w ith the .sr-only class and explicitly associated w ith the
f orm control it relates to using aria-describedby . Alternatively, ensure that the meaning (f or instance, the
f act that there is a w arning f or a particular text entry f ield) is conveyed in some other f orm, such as
changing the text of the actual <label> associated w ith the f orm control.
Although the f ollow ing examples already mention the validation state of their respective f orm controls in
the <label> text itself , the above technique (using .sr-only text and aria-describedby ) has been
included f or illustrative purposes.
EXAMPL E
Copy
Copy
09-Dec-14 12:40 PM
CSS Bootstrap
39 de 65
http://getbootstrap.com/css/
EXAMPL E
Copy
Copy
Control sizing
Set heights using classes like .input-lg , and set w idths using grid column classes like .col-lg-* .
Height sizing
Create taller or shorter f orm controls that match button sizes.
09-Dec-14 12:40 PM
CSS Bootstrap
40 de 65
http://getbootstrap.com/css/
EXAMPL E
.input-lg
Def ault input
.input-sm
.input-lg
Def ault select
.input-sm
Copy
Large labe l
Sm all labe l
Large input
Small input
Copy
09-Dec-14 12:40 PM
CSS Bootstrap
41 de 65
http://getbootstrap.com/css/
Column sizing
Wrap inputs in grid columns, or any custom parent element, to easily enf orce desired w idths.
EXAMPL E
.col-xs-2
.col-xs-3
.col-xs-4
<div class="row">
<div class="col-xs-2">
<input type="text" class="form-control" placeholder=".col-xs-2">
</div>
<div class="col-xs-3">
<input type="text" class="form-control" placeholder=".col-xs-3">
</div>
<div class="col-xs-4">
<input type="text" class="form-control" placeholder=".col-xs-4">
</div>
</div>
Copy
Help text
Block level help text f or f orm controls.
EXAMPL E
Input w ith he lp te xt
A block of help text that breaks onto a new line and may extend beyond one line.
Copy
Buttons
09-Dec-14 12:40 PM
CSS Bootstrap
42 de 65
http://getbootstrap.com/css/
Options
Use any of the available button classes to quickly create a styled button.
EXAMPL E
Def ault
Primary
Success
Inf o
Warning
Danger
Link
Copy
<!-- Provides extra visual weight and identifies the primary action in a set of buttons -->
<button type="button" class="btn btn-primary">Primary</button>
<!-- Indicates a successful or positive action -->
<button type="button" class="btn btn-success">Success</button>
<!-- Contextual button for informational alert messages -->
<button type="button" class="btn btn-info">Info</button>
<!-- Indicates caution should be taken with this action -->
<button type="button" class="btn btn-warning">Warning</button>
<!-- Indicates a dangerous or potentially negative action -->
<button type="button" class="btn btn-danger">Danger</button>
<!-- Deemphasize a button by making it look like a link while maintaining button behavior -->
<button type="button" class="btn btn-link">Link</button>
Sizes
Fancy larger or smaller buttons? Add .btn-lg , .btn-sm , or .btn-xs f or additional sizes.
EXAMPL E
Large button
Def ault button
Small button
Large button
Def ault button
Small button
09-Dec-14 12:40 PM
CSS Bootstrap
43 de 65
http://getbootstrap.com/css/
<p>
<button
<button
</p>
<p>
<button
<button
</p>
<p>
<button
<button
</p>
<p>
<button
<button
</p>
Create block level buttonsthose that span the f ull w idth of a parent by adding .btn-block .
EXAMPL E
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 (and include the aria-pressed="true" attribute) 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 f orce the same appearance, go ahead and
add .active .
EXAMPL E
Primary button
Button
Copy
09-Dec-14 12:40 PM
CSS Bootstrap
44 de 65
http://getbootstrap.com/css/
Anchor element
Add the .active class to <a> buttons.
EXAMPL E
Primary link
Link
Copy
Disabled state
Make buttons look unclickable by f ading them back w ith opacity .
Button element
Add the disabled attribute to <button> buttons.
EXAMPL E
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 f ix.
Anchor element
Add the .disabled class to <a> buttons.
EXAMPL E
Copy
We use .disabled as a utility class here, similar to the common .active class, so no pref ix is required.
CSS Bootstrap
45 de 65
http://getbootstrap.com/css/
This class uses pointer-events: none to try to disable the link f unctionality of <a> s, but that CSS
property is not yet standardized and isn't f ully supported in Opera 18 and below , or in Internet Explorer
11. In addition, even in brow sers that do support pointer-events: none , keyboard navigation remains
unaff ected, meaning that sighted keyboard users and users of assistive technologies w ill still be able to
activate these links. So to be saf e, 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.
EXAMPL E
Link
Button
Input
Submit
Copy
Cross-browser rendering
As a best practice, w e highly re com m e nd us ing the <button> e le m e nt w he ne ve r pos s ible to
ensure matching cross-brow ser rendering.
Among other things, there's a bug in Firef ox <30 (https://bugzilla.mozilla.org/show _bug.cgi?id=697451)
that prevents us f rom setting the line-height of <input> -based buttons, causing them to not exactly
match the height of other buttons on Firef ox.
Images
Responsive images
09-Dec-14 12:40 PM
CSS Bootstrap
46 de 65
http://getbootstrap.com/css/
Images in Bootstrap 3 can be made responsive-f riendly 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.
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 f or rounded corners.
EXAMPL E
140x140
140x140
140x140
Copy
Helper classes
Contextual colors
Convey meaning through color w ith a handf ul of emphasis utility classes. These may also be applied to links and
w ill darken on hover just like our def ault link styles.
EXAMPL E
09-Dec-14 12:40 PM
CSS Bootstrap
47 de 65
http://getbootstrap.com/css/
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 f ringilla.
<p
<p
<p
<p
<p
<p
class="text-muted">...</p>
class="text-primary">...</p>
class="text-success">...</p>
class="text-info">...</p>
class="text-warning">...</p>
class="text-danger">...</p>
Copy
Contextual backgrounds
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
Duis mollis, est non commodo luctus, nisi erat porttitor ligula.
Maecenas sed diam eget risus varius blandit sit amet non magna.
Copy
09-Dec-14 12:40 PM
CSS Bootstrap
48 de 65
http://getbootstrap.com/css/
<p
<p
<p
<p
<p
class="bg-primary">...</p>
class="bg-success">...</p>
class="bg-info">...</p>
class="bg-warning">...</p>
class="bg-danger">...</p>
Close icon
Use the generic close icon f or dismissing content like modals and alerts.
EXAMPL E
Copy
Carets
Use carets to indicate dropdow n f unctionality and direction. Note that the def ault caret w ill reverse automatically
in dropup menus (../components/#btn-dropdow ns-dropup).
EXAMPL E
<span class="caret"></span>
Copy
Quick floats
Float an element to the lef t or right w ith a class. !important is included to avoid specif icity issues. Classes can
also be used as mixins.
<div class="pull-left">...</div>
<div class="pull-right">...</div>
Copy
Copy
09-Dec-14 12:40 PM
CSS Bootstrap
49 de 65
http://getbootstrap.com/css/
// Classes
.pull-left {
float: left !important;
}
.pull-right {
float: right !important;
}
// Usage as mixins
.element {
.pull-left();
}
.another-element {
.pull-right();
}
Copy
// Classes
.center-block {
display: block;
margin-left: auto;
margin-right: auto;
}
Copy
// Usage as mixins
.element {
.center-block();
}
Clearfix
Easily clear float s by adding .clearfix to the pare nt e le m e nt. Utilizes the micro clearf ix
(http://nicolasgallagher.com/micro-clearf ix-hack/) as popularized by Nicolas Gallagher. Can also be used as a
mixin.
<!-- Usage as a class -->
<div class="clearfix">...</div>
Copy
Copy
09-Dec-14 12:40 PM
CSS Bootstrap
50 de 65
http://getbootstrap.com/css/
// Mixin itself
.clearfix() {
&:before,
&:after {
content: " ";
display: table;
}
&:after {
clear: both;
}
}
// Usage as a Mixin
.element {
.clearfix();
}
Furthermore, .invisible can be used to toggle only the visibility of an element, meaning its display is not
modif ied and the element can still aff ect the f low of the document.
<div class="show">...</div>
<div class="hidden">...</div>
Copy
// Classes
.show {
display: block !important;
}
.hidden {
display: none !important;
visibility: hidden !important;
}
.invisible {
visibility: hidden;
}
Copy
// Usage as mixins
.element {
.show();
}
.another-element {
.hidden();
}
09-Dec-14 12:40 PM
CSS Bootstrap
51 de 65
http://getbootstrap.com/css/
focusable to show the element again w hen it's f ocused (e.g. by a keyboard-only user). Necessary f or
f ollow ing accessibility best practices (../getting-started/#accessibility). Can also be used as mixins.
<a class="sr-only sr-only-focusable" href="#content">Skip to main content</a>
Copy
// Usage as a Mixin
.skip-navigation {
.sr-only();
.sr-only-focusable();
}
Copy
Image replacement
Utilize the .text-hide class or mixin to help replace an element's text content w ith a background image.
<h1 class="text-hide">Custom heading</h1>
Copy
// Usage as a Mixin
.heading {
.text-hide();
}
Copy
Responsive utilities
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 diff erent 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 f or toggling content across view port breakpoints.
Extra s m all de vice s
Sm all de vice s
M e dium de vice s
Large de vice s
Phones (<768px)
Tablets (768px)
Desktops (992px)
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
09-Dec-14 12:40 PM
CSS Bootstrap
52 de 65
http://getbootstrap.com/css/
Sm all de vice s
M e dium de vice s
Large de vice s
Phones (<768px)
Tablets (768px)
Desktops (992px)
Desktops (1200px)
.hidden-sm
Visible
Hidden
Visible
Visible
.hidden-md
Visible
Visible
Hidden
Visible
.hidden-lg
Visible
Visible
Visible
Hidden
As of v3.2.0, the .visible-*-* classes f or each breakpoint come in three variations, one f or each CSS
display property value listed below .
Group of clas s e s
CSS display
.visible-*-block
display: block;
.visible-*-inline
display: inline;
.visible-*-inline-block
display: inline-block;
So, f or extra small ( xs ) screens f or 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 de pre cate d as of
v3.2.0. They are approximately equivalent to .visible-*-block , except w ith additional special cases f or toggling
<table> -related elements.
Print classes
Similar to the regular responsive classes, use these f or toggling content f or print.
Clas s e s
Brow s e r
.visible-print-block
Hidden
Visible
Visible
Hidden
.visible-print-inline
.visible-print-inline-block
.hidden-print
The class .visible-print also exists but is de pre cate d as of v3.2.0. It is approximately equivalent to
.visible-print-block , except w ith additional special cases f or <table> -related elements.
Test cases
Resize your brow ser or load on diff erent devices to test the responsive utility classes.
Visible on...
Green checkmarks indicate the element is vis ible in your current view port.
Extra s m all
M e dium
Large
09-Dec-14 12:40 PM
CSS Bootstrap
53 de 65
http://getbootstrap.com/css/
Hidden on...
Here, green checkmarks also indicate the element is hidde n in your current view port.
Extra s m all
Hidde n on s m all
M e dium
Large
Using Less
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 f iles. To compile
the Less f iles, consult the Getting Started section (../getting-started/#grunt) f or 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 f ont stacks. For a complete breakdow n, please see the Customizer (../customize/#lessvariables-section).
09-Dec-14 12:40 PM
CSS Bootstrap
54 de 65
http://getbootstrap.com/css/
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 meaningf ul contextual
values.
EXAMPL E
@gray-darker:
@gray-dark:
@gray:
@gray-light:
@gray-lighter:
lighten(#000,
lighten(#000,
lighten(#000,
lighten(#000,
lighten(#000,
13.5%);
20%);
33.5%);
46.7%);
93.5%);
//
//
//
//
//
#222
#333
#555
#777
#eee
Copy
EXAMPL E
@brand-primary:
@brand-success:
@brand-info:
@brand-warning:
@brand-danger:
#428bca;
#5cb85c;
#5bc0de;
#f0ad4e;
#d9534f;
Copy
Use any of these color variables as they are or reassign them to more meaningf ul variables f or your project.
// Use as-is
.masthead {
background-color: @brand-primary;
}
Copy
Scaffolding
A handf ul of variables f or quickly customizing key elements of your site's skeleton.
Copy
09-Dec-14 12:40 PM
CSS Bootstrap
55 de 65
http://getbootstrap.com/css/
// Scaffolding
@body-bg:
#fff;
@text-color: @black-50;
Links
Easily style your links w ith the right color w ith only one value.
// Variables
@link-color:
@brand-primary;
@link-hover-color: darken(@link-color, 15%);
Copy
// Usage
a {
color: @link-color;
text-decoration: none;
&:hover {
color: @link-hover-color;
text-decoration: underline;
}
}
Note that the @link-hover-color uses a f unction, another aw esome tool f rom Less, to automagically create the
right hover color. You can use darken , lighten , saturate , and desaturate .
Typography
Easily set your type f ace, text size, leading, and more w ith a f ew quick variables. Bootstrap makes use of these
as w ell to provide easy typographic mixins.
@font-family-sans-serif:
@font-family-serif:
@font-family-monospace:
@font-family-base:
@font-size-base:
@font-size-large:
@font-size-small:
14px;
ceil((@font-size-base * 1.25)); // ~18px
ceil((@font-size-base * 0.85)); // ~12px
@font-size-h1:
@font-size-h2:
@font-size-h3:
@font-size-h4:
@font-size-h5:
@font-size-h6:
@line-height-base:
@line-height-computed:
1.428571429; // 20/14
floor((@font-size-base * @line-height-base)); // ~20px
@headings-font-family:
@headings-font-weight:
@headings-line-height:
@headings-color:
inherit;
500;
1.1;
inherit;
Copy
09-Dec-14 12:40 PM
CSS Bootstrap
56 de 65
http://getbootstrap.com/css/
Icons
Tw o quick variables f or customizing the location and f ilename of your icons.
@icon-font-path:
@icon-font-name:
"../fonts/";
"glyphicons-halflings-regular";
Copy
Components
Components throughout Bootstrap make use of some def ault variables f or setting common values. Here are the
most commonly used.
@padding-base-vertical:
@padding-base-horizontal:
6px;
12px;
@padding-large-vertical:
@padding-large-horizontal:
10px;
16px;
@padding-small-vertical:
@padding-small-horizontal:
5px;
10px;
@padding-xs-vertical:
@padding-xs-horizontal:
1px;
5px;
@line-height-large:
@line-height-small:
1.33;
1.5;
@border-radius-base:
@border-radius-large:
@border-radius-small:
4px;
6px;
3px;
@component-active-color:
@component-active-bg:
#fff;
@brand-primary;
@caret-width-base:
@caret-width-large:
4px;
5px;
Copy
Vendor mixins
Vendor mixins are mixins to help support multiple brow sers by including all relevant vendor pref ixes in your
compiled CSS.
Box-sizing
Reset your components' box model w ith a single mixin. For context, see this helpf ul article f rom Mozilla
(https://developer.mozilla.org/en-US/docs/CSS/box-sizing).
The mixin is de pre cate d as of v3.2.0, w ith the introduction of autopref ixer. To preserve backw ardscompatibility, Bootstrap w ill continue to use the mixin internally until Bootstrap v4.
.box-sizing(@box-model) {
-webkit-box-sizing: @box-model; // Safari <= 5
-moz-box-sizing: @box-model; // Firefox <= 19
box-sizing: @box-model;
}
Copy
09-Dec-14 12:40 PM
CSS Bootstrap
57 de 65
http://getbootstrap.com/css/
Rounded corners
Today all modern brow sers support the non-pref ixed border-radius property. As such, there is no .borderradius() mixin, but Bootstrap does include shortcuts f or quickly rounding tw o corners on a particular side of an
object.
.border-top-radius(@radius) {
border-top-right-radius: @radius;
border-top-left-radius: @radius;
}
.border-right-radius(@radius) {
border-bottom-right-radius: @radius;
border-top-right-radius: @radius;
}
.border-bottom-radius(@radius) {
border-bottom-right-radius: @radius;
border-bottom-left-radius: @radius;
}
.border-left-radius(@radius) {
border-bottom-left-radius: @radius;
border-top-left-radius: @radius;
}
Copy
Copy
Transitions
Multiple mixins f or f lexibility. Set all transition inf ormation w ith one, or specif y a separate delay and duration as
needed.
The mixins are de pre cate d as of v3.2.0, w ith the introduction of autopref ixer. To preserve backw ardscompatibility, Bootstrap w ill continue to use the mixins internally until Bootstrap v4.
Copy
09-Dec-14 12:40 PM
CSS Bootstrap
58 de 65
http://getbootstrap.com/css/
.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;
}
Transformations
Rotate, scale, translate (move), or skew any object.
The mixins are de pre cate d as of v3.2.0, w ith the introduction of autopref ixer. To preserve backw ardscompatibility, Bootstrap w ill continue to use the mixins internally until Bootstrap v4.
Copy
09-Dec-14 12:40 PM
CSS Bootstrap
59 de 65
http://getbootstrap.com/css/
.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;
}
Animations
A single mixin f or using all of CSS3's animation properties in one declaration and other mixins f or individual
properties.
09-Dec-14 12:40 PM
CSS Bootstrap
60 de 65
http://getbootstrap.com/css/
The mixins are de pre cate d as of v3.2.0, w ith the introduction of autopref ixer. To preserve backw ardscompatibility, Bootstrap w ill continue to use the mixins internally until Bootstrap v4.
.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;
}
Copy
Opacity
Set the opacity f or all brow sers and provide a filter f allback f or IE8.
.opacity(@opacity) {
opacity: @opacity;
// IE8 filter
@opacity-ie: (@opacity * 100);
filter: ~"alpha(opacity=@{opacity-ie})";
}
Copy
Placeholder text
Provide context f or f orm controls w ithin each f ield.
.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
}
Copy
Columns
09-Dec-14 12:40 PM
CSS Bootstrap
61 de 65
http://getbootstrap.com/css/
Copy
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 pref ixed syntaxes you'll need.
#gradient > .vertical(#333; #000);
#gradient > .horizontal(#333; #000);
#gradient > .radial(#333; #000);
Copy
You can also specif y the angle of a standard tw o-color, linear gradient:
#gradient > .directional(#333; #000; 45deg);
Copy
If you need a barber-stripe style gradient, that's easy, too. Just specif y a single color and w e'll overlay a
translucent w hite stripe.
#gradient > .striped(#333; 45deg);
Copy
Up the ante and use three colors instead. Set the f irst color, the second color, the second color's color stop (a
percentage value like 25%), and the third color w ith these mixins:
#gradient > .vertical-three-colors(#777; #333; 25%; #000);
#gradient > .horizontal-three-colors(#777; #333; 25%; #000);
Copy
He ads up! Should you ever need to remove a gradient, be sure to remove any IE-specif ic filter you may
have added. You can do that by using the .reset-filter() mixin alongside background-image: none; .
Utility mixins
Utility mixins are mixins that combine otherw ise unrelated CSS properties to achieve a specif ic goal or task.
Clearfix
Forget adding class="clearfix" to any element and instead add the .clearfix() mixin w here appropriate.
Uses the micro clearf ix (http://nicolasgallagher.com/micro-clearf ix-hack/) f rom Nicolas Gallager
(https://tw itter.com/necolas).
Copy
09-Dec-14 12:40 PM
CSS Bootstrap
62 de 65
http://getbootstrap.com/css/
// Mixin
.clearfix() {
&:before,
&:after {
content: " ";
display: table;
}
&:after {
clear: both;
}
}
// Usage
.container {
.clearfix();
}
Horizontal centering
Quickly center any element w ithin its parent. Re quire s width or max-width to be s e t.
// Mixin
.center-block() {
display: block;
margin-left: auto;
margin-right: auto;
}
Copy
// Usage
.container {
width: 940px;
.center-block();
}
Sizing helpers
Specif y the dimensions of an object more easily.
// Mixins
.size(@width; @height) {
width: @width;
height: @height;
}
.square(@size) {
.size(@size; @size);
}
Copy
// Usage
.image { .size(400px; 300px); }
.avatar { .square(48px); }
Resizable textareas
Easily conf igure the resize options f or any textarea, or any other element. Def aults to normal brow ser behavior
( both ).
09-Dec-14 12:40 PM
CSS Bootstrap
63 de 65
http://getbootstrap.com/css/
.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. Re quire s e le m e nt to be block or inline-block
le ve l.
Copy
// Mixin
.text-overflow() {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
// Usage
.branch-name {
display: inline-block;
max-width: 200px;
.text-overflow();
}
Retina images
Specif y tw o image paths and the @1x image dimensions, and Bootstrap w ill provide an @2x media query. If
you have m any im age s to s e rve , cons ide r w riting your re tina im age CSS m anually in a s ingle
m e dia que ry.
.img-retina(@file-1x; @file-2x; @width-1x; @height-1x) {
background-image: url("@{file-1x}");
@media
only screen and (-webkit-min-device-pixel-ratio:
only screen and (
min--moz-device-pixel-ratio:
only screen and (
-o-min-device-pixel-ratio:
only screen and (
min-device-pixel-ratio:
only screen and (
min-resolution:
only screen and (
min-resolution:
background-image: url("@{file-2x}");
background-size: @width-1x @height-1x;
}
Copy
2),
2),
2/1),
2),
192dpi),
2dppx) {
}
// Usage
.jumbotron {
.img-retina("/img/bg-1x.png", "/img/bg-2x.png", 100px, 100px);
}
09-Dec-14 12:40 PM
CSS Bootstrap
64 de 65
http://getbootstrap.com/css/
Using Sass
While Bootstrap is built on Less, it also has an official Sass port
(https://github.com/twbs/bootstrap-sass). 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 diff erent audience, the contents of the project
diff er greatly f rom the main Bootstrap project. This ensures the Sass port is as compatible w ith as many
Sass-based systems as possible.
Path
De s cription
lib/
Ruby gem code (Sass conf iguration, Rails and Compass integrations)
tasks/
test/
Compilation tests
templates/
vendor/assets/
Rakefile
Visit the Sass port's GitHub repository (https://github.com/tw bs/bootstrap-sass) to see these f iles in action.
Installation
For inf ormation on how to install and use Bootstrap f or Sass, consult the GitHub repository readme
(https://github.com/tw bs/bootstrap-sass). It's the most up to date source and includes inf ormation f or use w ith
Rails, Compass, and standard Sass projects.
Star
75,064
Fork
28,459
Follow @twbootstrap
246K followers
Tweet
5,279
Designed and built w ith all the love in the w orld by @mdo (https://tw itter.com/mdo) and @f at (https://tw itter.com
/f at).
Maintained by the core team (https://github.com/orgs/tw bs/people) w ith the help of our contributors
(https://github.com/tw bs/bootstrap/graphs/contributors).
09-Dec-14 12:40 PM
CSS Bootstrap
65 de 65
http://getbootstrap.com/css/
09-Dec-14 12:40 PM