Shocrtcodes - Base Css

Headings & body copy

Typographic scale

The entire typographic grid is based on two Less variables in our variables.less file: @baseFontSize and @baseLineHeight. The first is the base font-size used throughout and the second is the base line-height.

We use those variables, and some math, to create the margins, paddings, and line-heights of all our type and more.

Using emphasis

Note: Feel free to use <b> and <i> in HTML5, but their usage has changed a bit. <b> is meant to highlight words or phrases without conveying additional importance while <i> is mostly for voice, technical terms, etc.

Forms

Flexible HTML and CSS

The best part about forms in Bootstrap is that all your inputs and controls look great no matter how you build them in your markup. No superfluous HTML is required, but we provide the patterns for those who require it.

More complicated layouts come with succinct and scalable classes for easy styling and event binding, so you're covered at every step.

Four layouts included

Bootstrap comes with support for four types of form layouts:

Vertical (default)

Search

Inline

Horizontal

Different types of form layouts require some changes to markup, but the controls themselves remain and behave the same.

Control states and more

Bootstrap's forms include styles for all the base form controls like input, textarea, and select you'd expect. But it also comes with a number of custom components like appended and prepended inputs and support for lists of checkboxes.

States like error, warning, and success are included for each type of form control. Also included are styles for disabled controls.

Four types of forms

Bootstrap provides simple markup and styles for four styles of common web forms.

Form control states

Bootstrap features styles for browser-supported focused and disabled states. We remove the default Webkit outline and apply a box-shadow in its place for :focus.

Form validation

It also includes validation styles for errors, warnings, and success. To use, add the error class to the surrounding .control-group.

<fieldset
class="control-group error">
…
</fieldset>

Focused input

Uneditable input

Some value here

Disabled input

Disabled checkbox

This is a disabled checkbox

Input with warning

Something may have gone wrong

Input with error

Please correct the error

Input with success

Woohoo!

Select with success

Woohoo!

Extending form controls

Prepend & append inputs

Input groups—with appended or prepended text—provide an easy way to give more context for your inputs. Great examples include the @ sign for Twitter usernames or $ for finances.

Checkboxes and radios

Up to v1.4, Bootstrap required extra markup around checkboxes and radios to stack them. Now, it's a simple matter of repeating the <label class="checkbox"> that wraps the <input type="checkbox">.

Inline checkboxes and radios are also supported. Just add .inline to any .checkbox or .radio and you're done.

Inline forms and append/prepend

To use prepend or append inputs in an inline form, be sure to place the .add-on and input on the same line, without spaces.

Form help text

To add help text for your form inputs, include inline help text with <span class="help-inline"> or a help text block with <p class="help-block"> after the input element.

Form grid sizes

Use the same .span* classes from the grid system for input sizes.

Alternate sizes

You may also use static classes that don't map to the grid, adapt to the responsive CSS styles, or account for varying types of controls (e.g., input vs. select).

Prepended text

@

Here's some help text

Appended text

.00

Here's more help text

Append and prepend

$.00

Append with button

Two-button append

Inline checkboxes

1
2
3

Checkboxes

Option one is this and that—be sure to include why it's great
Option two can also be checked and included in form results
Option three can—yes, you guessed it—also be checked and included in form results

Note: Labels surround all the options for much larger click areas and a more usable form.

Radio buttons

Option one is this and that—be sure to include why it's great
Option two can be something else and selecting it will deselect option one

Buttons

Button

class=""

Description

btn

Standard gray button with gradient

btn btn-primary

Provides extra visual weight and identifies the primary action in a set of buttons

btn btn-info

Used as an alternative to the default styles

btn btn-success

Indicates a successful or positive action

btn btn-warning

Indicates caution should be taken with this action

btn btn-danger

Indicates a dangerous or potentially negative action

btn btn-inverse

Alternate dark gray button, not tied to a semantic action or use

Buttons for actions

As a convention, buttons should only be used for actions while hyperlinks are to be used for objects. For instance, "Download" should be a button while "recent activity" should be a link.

Button styles can be applied to anything with the .btn class applied. However, typically you'll want to apply these to only <a> and <button> elements.

Built as a sprite

Instead of making every icon an extra request, we've compiled them into a sprite—a bunch of images in one file that uses CSS to position the images with background-position. This is the same method we use on Twitter.com and it has worked well for us.

All icons classes are prefixed with .icon- for proper namespacing and scoping, much like our other components. This will help avoid conflicts with other tools.

Glyphicons has granted us use of the Halflings set in our open-source toolkit so long as we provide a link and credit here in the docs. Please consider doing the same in your projects.

How to use

Bootstrap uses an <i> tag for all icons, but they have no case class—only a shared prefix. To use, place the following code just about anywhere:

<i class="icon-search"></i>

There are also styles available for inverted (white) icons, made ready with one extra class:

<i class="icon-search icon-white"></i>

There are 140 classes to choose from for your icons. Just add an <i> tag with the right classes and you're set. You can find the full list in sprites.less or right here in this document.

Heads up!
When using beside strings of text, as in buttons or nav links, be sure to leave a space after the <i> tag for proper spacing.

Use cases

Icons are great, but where would one use them? Here are a few ideas:

As visuals for your sidebar navigation

For a purely icon-driven navigation

For buttons to help convey the meaning of an action

With links to share context on a user's destination

Essentially, anywhere you can put an <i> tag, you can put an icon.

Examples

Use them in buttons, button groups for a toolbar, navigation, or prepended form inputs.