Saturday, 18 April 2015

Bootstrap Text/Typography



Bootstrap's Default Settings:
Bootstrap's global default font-size is 14px, with a line-height of 1.428.
This is applied to the <body> and all paragraphs.
In addition, all <p> elements have a bottom margin that equals half their computed line-height (10px by default).

Bootstrap vs. Browser Defaults

In this chapter, we will look at some HTML elements that will be styled a little bit different by Bootstrap than browser defaults.

<h1> - <h6>

By default, Bootstrap will style the HTML headings (<h1> to <h6>) in the following way:
<div class="container">
  <h1>h1 Bootstrap heading (36px)</h1>
  <h2>h2 Bootstrap heading (30px)</h2>
  <h3>h3 Bootstrap heading (24px)</h3>
  <h4>h4 Bootstrap heading (18px)</h4>
  <h5>h5 Bootstrap heading (14px)</h5>
  <h6>h6 Bootstrap heading (12px)</h6>
</div>



<small>

In Bootstrap the HTML <small> element is used to create a lighter, secondary text in any heading:
<div class="container">
  <h1>Lighter, Secondary Text</h1>
  <p>The small element is used to create a lighter, secondary text in any heading:</p>      
  <h1>h1 heading <small>secondary text</small></h1>
  <h2>h2 heading <small>secondary text</small></h2>
  <h3>h3 heading <small>secondary text</small></h3>
  <h4>h4 heading <small>secondary text</small></h4>
  <h5>h5 heading <small>secondary text</small></h5>
  <h6>h6 heading <small>secondary text</small></h6>
</div>

 

<mark>

Bootstrap will style the HTML <mark> element in the following way:
<p>Use the mark element to <mark>highlight</mark> text.</p>
Use the mark element to highlight text.

 

<abbr>

Bootstrap will style the HTML <abbr> element in the following way:
<p>The <abbr title="World Health Organization">WHO</abbr> was founded in 1948.</p>

 

<blockquote>

Bootstrap will style the HTML <blockquote> element in the following way:
<div class="container">
  <h1>Blockquotes</h1>
  <p>The blockquote element is used to present content from another source:</p>
  <blockquote>
    <p>For 50 years, WWF has been protecting the future of nature. The world's leading conservation organization, WWF works in 100 countries and is supported by 1.2 million members in the United States and close to 5 million globally.</p>
    <footer>From WWF's website</footer>
  </blockquote>
</div>

To show the quote on the right, use the .blockquote-reverse class:
<div class="container">
  <h1>Blockquotes</h1>
  <p>To show the quote on the right use the class .blockquote-reverse:</p>
  <blockquote class="blockquote-reverse">
    <p>For 50 years, WWF has been protecting the future of nature. The world's leading conservation organization, WWF works in 100 countries and is supported by 1.2 million members in the United States and close to 5 million globally.</p>
    <footer>From WWF's website</footer>
  </blockquote>
</div>



<dl>

Bootstrap will style the HTML <dl> element in the following way; The dl element indicates a description list:
<div class="container">
  <h1>Description Lists</h1>   
  <p>The dl element indicates a description list:</p>
  <dl>
    <dt>Coffee</dt>
    <dd>- black hot drink</dd>
    <dt>Milk</dt>
    <dd>- white cold drink</dd>
  </dl>    
</div>


<code>

Bootstrap will style the HTML <code> element in the following way:
<div class="container">
  <h1>Code Snippets</h1>
  <p>Inline snippets of code should be embedded in the code element:</p>
  <p>The following HTML elements: <code>span</code>, <code>section</code>, and <code>div</code> defines a section in a document.</p>
</div>


<kbd>

Bootstrap will style the HTML <kbd> element in the following way:
<div class="container">
  <h1>Keyboard Inputs</h1>
  <p>To indicate input that is typically entered via the keyboard, use the kbd element:</p>
  <p>Use <kbd>ctrl + p</kbd> to open the Print dialog box.</p>
</div>


<pre>

Bootstrap will style the HTML <pre> element in the following way:
<div class="container">
<h1>Multiple Code Lines</h1>
<p>For multiple lines of code, use the pre element:</p>
<pre>
Text in a pre element
is displayed in a fixed-width
font, and it preserves
both      spaces and
line breaks.
</pre>
</div>


Contextual Colors and Backgrounds

Bootstrap also has some contextual classes that can be used to provide "meaning through colors".
The classes for text colors are:.text-muted, .text-primary, .text-success, .text-info, .text-warning, and .text-danger:
<div class="container">
  <h2>Contextual Colors</h2>
  <p>Use the contextual classes to provide "meaning through colors":</p>
  <p class="text-muted">This text is muted.</p>
  <p class="text-primary">This text is important.</p>
  <p class="text-success">This text indicates success.</p>
  <p class="text-info">This text represents some information.</p>
  <p class="text-warning">This text represents a warning.</p>
  <p class="text-danger">This text represents danger.</p>
</div>

The classes for background colors are:.bg-primary, .bg-success, bg-info, bg-warning, and .bg-danger:
<div class="container">
  <h2>Contextual Backgrounds</h2>
  <p>Use the contextual background classes to provide "meaning through colors":</p>
  <p class="bg-primary">This text is important.</p>
  <p class="bg-success">This text indicates success.</p>
  <p class="bg-info">This text represents some information.</p>
  <p class="bg-warning">This text represents a warning.</p>
  <p class="bg-danger">This text represents danger.</p>
</div>

 

More Typography Classes

The Bootstrap classes below can be added to style HTML elements further:
Class
Description
.lead
Makes a paragraph stand out
.small
Indicates smaller text (set to 85% of the size of the parent)
.text-left
Indicates left-aligned text
.text-center
Indicates center-aligned text
.text-right
Indicates right-aligned text
.text-justify
Indicates justified text
.text-nowrap
Indicates no wrap text
.text-lowercase
Indicates lowercased text
.text-uppercase
Indicates uppercased text
.text-capitalize
Indicates capitalized text
.initialism
Displays the text inside an <abbr> element in a slightly smaller font size
.list-unstyled
Removes the default list-style and left margin on list items (works on both <ul> and<ol>). This class only applies to immediate children list items (to remove the default list-style from any nested lists, apply this class to any nested lists as well)
.list-inline
Places all list items on a single line
.dl-horizontal
Lines up the terms (<dt>) and descriptions (<dd>) in <dl> elements side-by-side. Starts off like default <dl>s, but when the browser window expands, it will line up side-by-side
.pre-scrollable
Makes a <pre> element scrollable


No comments:

Post a Comment