Latest web development tutorials

Bootstrap auxiliary class

This chapter discusses some of the Bootstrap might come in handy helper classes.

text

The following different classes show different text colors. If the text is a link to move the mouse over the text will be dimmed:

class description Examples
.text-muted Text Style "text-muted" category try it
.text-primary Text Style "text-primary" category try it
.text-success Text Style "text-success" category try it
.text-info Text Style "text-info" category try it
.text-warning Text Style "text-warning" category try it
.text-danger Text Style "text-danger" category try it

background

The following different classes shows different background colors. If the text is a link to move the mouse over the text will be dimmed:

class description Examples
.bg-primary Table cell using the "bg-primary" category try it
.bg-success Table cell using the "bg-success" category try it
.bg-info Table cell using the "bg-info" category try it
.bg-warning Table cell using the "bg-warning" category try it
.bg-danger Table cell using the "bg-danger" category try it

other

class description Examples
.pull-left Elements float to the left try it
.pull-right Elements float to the right try it
.center-block Element is set display: block and centered try it
.clearfix Clear float try it
.show Mandatory elements are displayed try it
.hidden Compulsory element hiding try it
.sr-only In addition to the screen reader, the hidden element on other devices try it
.sr-only-focusable In conjunction with .sr-only class, displayed when the element gets focus (such as: user's keyboard operation) try it
.text-hide The text page elements contained replace background try it
.close Display Off button try it
.caret Display drop-down menu try it

More examples

Close icon

Use common Close icon to close the modal box and the alert box. Useclass close to get close icon.

Examples

<P> Close icon instance <button type = "button" class = "close" aria-hidden = "true"> & times; </ Button> </ P>

try it"

The results are as follows:

Close icon

Caret

Use caret to pull down the function and direction. Use <span> element withclass caret to get this feature.

Examples

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

try it"

The results are as follows:

Caret

Fast floating

You can use eachclass pull-left pull-rightor to the left or right-floating elements. The following example illustrates this point.

Examples

<Div class = "pull-left"> Quick left floating </ div> <Div class = "pull-right"> right quickly floating </ div>

try it"

The results are as follows:

Fast floating

To align the components of the navigation bar, use.navbar-left or .navbar-rightinstead. See the Bootstrap navigation bar .

Centered content

Useclass center-block to center elements.

Examples

<Div class = "row"> <Div class = "center-block" style = "width: 200px; background -color: #ccc;"> This is the center-block instance </ div> </ Div>

try it"

The results are as follows:

Centered content block

Clear float

To clear the floating element, use.clearfix class.

Examples

<Div class = "clearfix" style = "background: # D8D8D8; border: 1px solid # 000; padding: 10px;"> <Div class = "pull-left" style = "background: # 58D3F7; "> Quick left floating </ div> <Div class = "pull-right" style = "background: # DA81F5; "> right quickly floating </ div> </ Div>

try it"

The results are as follows:

Clear float

Show and hide content

You can force the element to display or hide (including screen readers) through the use ofclass .show and .hiddencome.

Examples

<Div class = "row" style = "padding: 91px 100px 19px 50px;"> <Div class = "show" style = "left-margin: 10px ; width: 300px; background-color: #ccc;"> This is an example of the show class </ div> <Div class = "hidden" style = "width: 200px; background -color: #ccc;"> This is an example of the hide class </ div> </ Div>

try it"

The results are as follows:

Show and hide content

Screen reader

You can put all the elements on the device by using a hiddenclass .sr-only, in addition to a screen reader.

Examples

<Div class = "row" style = "padding: 91px 100px 19px 50px;"> <Form class = "form-inline" role = "form"> <Div class = "form-group"> <Label class = "sr-only" for = "email"> Email address </ label> <Input type = "email" class = "form-control" placeholder = "Enter email"> </ Div> <Div class = "form-group"> <Label class = "sr-only" for = "pass"> password </ label> <Input type = "password" class = "form-control" placeholder = "Password"> </ Div> </ Form> </ Div>

try it"

The results are as follows:

Screen reader

Here we see two types of label input tags withclass sr-only, so the label will only be visible to screen readers.