Instead of making every icon an extra request, we've compiled them into a sprite—a bunch of images in one file that uses CSS to position the images with
background-position. This is the same method we use on Twitter.com and it has worked well for us.
All icons classes are prefixed with
.icon- for proper namespacing and scoping, much like our other components. This will help avoid conflicts with other tools.
Glyphicons has granted us use of the Halflings set in our open-source toolkit so long as we provide a link and credit here in the docs. Please consider doing the same in your projects.
Bootstrap uses an
<i> tag for all icons, but they have no case class—only a shared prefix. To use, place the following code just about anywhere:
There are also styles available for inverted (white) icons, made 阅读y with one extra class:
<i class="icon-search icon-white"></i>
There are 120 classes to choose from for your icons. Just add an
<i> tag with the right classes and you're set. You can find the full list in sprites.less or right here in this document.
When using beside strings of text, as in buttons or nav links, be sure to leave a space after the
<i> tag for proper spacing.
Icons are great, but where would one use them? Here are a few ideas:
Essentially, anywhere you can put an
<i> tag, you can put an icon.
Use them in buttons, button groups for a toolbar, navigation, or prepended form inputs.
The best part 关于 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.
更多 complicated layouts come with succinct and scalable classes for easy styling and event binding, so you're covered at every step.
Bootstrap comes with support for four types of form layouts:
Different types of form layouts require some changes to markup, but the controls themselves remain and behave the same.
Bootstrap's forms include styles for all the base form controls like input, textarea, and select you'd expect. But it also comes with a number of custom components like appended and prepended inputs and support for lists of checkboxes.
States like error, warning, and success are included for each type of form control. Also included are styles for disabled controls.
Bootstrap provides simple markup and styles for four styles of common web forms.
||Stacked, left-aligned labels over controls|
||Left-aligned label and inline-block controls for compact style|
||Extra-rounded text input for a typical search aesthetic|
||Float left, right-aligned labels on same line as controls|
With v2.0, we have lighter and smarter defaults for form styles. No extra markup, just form controls.
<form class="well"> <label>Label name</label> <input type="text" class="span3" placeholder="Type something"> <span class="help-inline">Associated help text!</span> <label class="checkbox"> <input type="checkbox"> Check me out </label> <button type="submit" class="btn">Submit</button> </form>
Reflecting default WebKit styles, just add
.form-search for extra rounded search fields.
<form class="well form-search"> <input type="text" class="input-medium search-query"> <button type="submit" class="btn">Search</button> </form>
Inputs are block level to start. For
.form-horizontal, we use inline-block.
<form class="well form-inline"> <input type="text" class="input-small" placeholder="Email"> <input type="password" class="input-small" placeholder="Password"> <label class="checkbox"> <input type="checkbox"> Remember me </label> <button type="submit" class="btn">Sign in</button> </form>