beginner
beginner

Reputation: 303

Bootstrap way to add vertical space between the fields

How can I add vertical space between the div's. Is there any bootstrap class I can add here? Any help?

Below is the snippet from my code:

<div class="row">
    <div class="col-md-6">
        <div class="form-group">
            <label class="control-label col-lg-4"> Project: </label>
            <div class="col-lg-8">
                @Html.TextBoxFor(model => model.detailsConfig.Project, new { onkeypress = "return isNumberKey(event)", @class = "form-control", id = "Project" })
            </div>
        </div>
    </div>
</div>

<div class="row">
    <div class="col-md-6">
        <div class="form-group">
            <label class="control-label col-lg-4">Quantity:</label>
            <div class="col-lg-8">
                @Html.TextBoxFor(model => model.detailsConfig.Quantity, new { onkeypress = "return isNumberKey(event)", @class = "form-control", id = "Quantity" })
            </div>
        </div>
    </div>
</div>

Upvotes: 4

Views: 6670

Answers (5)

Wakil Ahmed
Wakil Ahmed

Reputation: 1393

I just found out about gutter. It can used both horizontally and vertiacally in the following way:

g-2
gx-2
gy-2

Read more about it here.

Upvotes: 0

Ridge
Ridge

Reputation: 11

You could use this : <div class="d-flex align-content-around flex-wrap">

Upvotes: 0

Adam H
Adam H

Reputation: 172

You can add the class "mt-#" or to your divs to add top margin, where # is a number between 1-5, varying in lengths. If you want to add margin to the top and bottom, you can do "my-#." This class is part of Bootstrap documentation.

<div class="your-class mt-3">Your column</div>

Upvotes: 1

R&#233;my Testa
R&#233;my Testa

Reputation: 897

There are no class in the bootstrap toolbox to do this.

So the best way to do it's to add a top-buffer class on your row.

.top-buffer{
  margin-top: 40px;
}

Here the codepen : https://codepen.io/boydow/pen/ayZeGW

Upvotes: 1

Rohit Verma
Rohit Verma

Reputation: 3785

You need to use <div class="form-group"> as parents like this

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<div class="form-group">
<div class="row">
<div class="col-md-12">
            <div class="col-md-6">
              
                    <label class="control-label col-lg-4"> Project: </label>
                    <div class="col-lg-8">
                        @Html.TextBoxFor(model => model.detailsConfig.Project, new { onkeypress = "return isNumberKey(event)", @class = "form-control", id = "Project" })
                    </div>
                    </div>
            </div>
            </div>

        </div>

  <div class="form-group">
     <div class="row">
     <div class="col-md-12">
            <div class="col-md-6">
              
                    <label class="control-label col-lg-4">Quantity:</label>
                    <div class="col-lg-8">
                        @Html.TextBoxFor(model => model.detailsConfig.Quantity, new { onkeypress = "return isNumberKey(event)", @class = "form-control", id = "Quantity" })
                    </div>
                </div>
            </div>
</div>
           </div>
           

Upvotes: 4

Related Questions