user866933 user866933 - 3 months ago 7
CSS Question

How to add a space to the left of bootsrap row?

I would like to know what is the best way to add space to the left side of
a bootsrap row, which uses col-sm-*.
I was able to achieve it using an empty div as shown below.

<div class="row">
<div class="col-sm-1" >
<!-- I want to remove this div -->
</div>
<div class="col-sm-2" >
Text1
</div>
<div class="col-sm-3">
Text2
</div>
<div class="col-sm-3">
Text3
</div>
<div class="col-sm-3">
Text4
</div>
</div>


But that's not a nice way. How we can do it without using empty div?

Answer

Use this code:

.col-sm-2 col-sm-offset-1

in the second div as below:

<div class="row">                
            <div class="col-sm-2 col-sm-offset-1" >
                Text1
            </div>
            <div class="col-sm-3">
                Text2
            </div>
            <div class="col-sm-3">
                Text3 
            </div>
            <div class="col-sm-3">
                Text4
            </div>
       </div>