Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reduce spacing between rows

I am using Bootstrap grid system. The spacing between rows is too large.

How can I reduce it?

<div class="row">
  <div class="col-md-6">
    <h1 id="Heading"> Heading </h1>
    <div class="row" style="margin-left:6px;">
      <div class="col-md-12">
        <div class="row">
          <div class="col-md-12">
            <div id="rect"> <span id="Heading" style="margin-left:15px;font-weight:bold; font-size: 18pt;color: #2373B3;"> Span </span> </div>
          </div>
        </div>
        <div class="row">
          <div class="col-md-12">
            <div id="rect"> <span id="Heading" style="margin-left:15px;font-weight:bold; font-size: 18pt;color: #2373B3;"> Span  </span> </div>
          </div>
        </div>
        <div class="row">
          <div class="col-md-12">
            <div id="rect"> <span id="Heading" style="margin-left:15px;font-weight:bold; font-size: 18pt;color: #2373B3;"> Span  </span> </div>
          </div>
        </div>
        <div class="row">
          <div class="col-md-12">
            <div id="rect"> <span id="Heading" style="margin-left:15px;font-weight:bold; font-size: 18pt;color: #2373B3;"> Span  </span> </div>
          </div>
        </div>
      </div>
    </div>
  </div>
<div>
like image 640
user3026519 Avatar asked Apr 24 '14 06:04

user3026519


Video Answer


3 Answers

There are 2 quick solutions possible for this:

  1. Edit bootstrap core css/sass which will be a bad idea as it will affect core functionality of page scaffolding.
  2. Write a separate class and add it in your div for ex:

.row-bottom-margin { margin-bottom:20px; }

and you can use it as

<div class="row row-bottom-margin">

Option 1 is not suggested until unless you are really looking for this change to be applied at all the relevant places and do consider your future designs.

Hope this helps!

like image 52
Soman Dubey Avatar answered Oct 19 '22 03:10

Soman Dubey


By default, row elements expands in related to their childs. So your problem is not in .row class but in #rect

On rect element you have a line-height of 1.4 by default bootstrap css. Make it a class rather than id.

You can reduce it to 1.2 for your case... Do it on a separate css file and overwrite it. That would be a better design for you.

 .rect {        
    line-height: 1.2; // overwrite it on a different css if you prefer        
}
like image 1
Yagiz Ozturk Avatar answered Oct 19 '22 05:10

Yagiz Ozturk


Using Bootstrap 4 now you no more need to use any CSS for this as it has utility classes for this purpose.

like image 2
tom Avatar answered Oct 19 '22 04:10

tom