Bootstrap also includes a few helper classes that we can use to adapt our layout. Let's take a look at some examples.
Floating classes of Bootstrap will help you to create a decent layout on the web. Here are two Bootstrap classes to pull your elements left and right:
<div class="pull-left">...</div> <div class="pull-right">...</div>
When we are using floats on elements, we need to wrap our floated elements in a clearfix
class. This will clear the elements and you will be able to see the actual height of the container element:
<div class="helper-classes"> <div class="pull-left">...</div> <div class="pull-right">...</div> <div class="clearfix"> </div>
If the float
classes are directly within an element with the row
class, then our floats are cleared automatically by Bootstrap and the clearfix
class does not need to be applied manually.
To make it center block-level elements, Bootstrap allows this with the center-block
class:
<div class="center-block">...</div>
This will set your element property margin-left
and margin-right
properties to auto
, which will center the element.
You may wish to show and hide elements with CSS, and Bootstrap gives you a couple of classes to do this:
<div class="show">...</div> <div class="hidden">...</div>