What\'s the best way to add vertical whitespace using Twitter\'s Bootstrap?
For example, let\'s say that I am creating a landing page and would like a bit (100px) o
Just use <br/>. I found myself here looking for the answer to this question and then felt sort of silly for not thinking about using a simple line break as suggested by user JayKilleen in a comment.
In v2, there isn't anything built-in for that much vertical space, so you'll want to stick with a custom class. For smaller heights, I usually just throw a <div class="control-group"> around a button.
I merely created a div class using various heights i.e.
<div class="divider-10"></div>
The CSS is:
.divider-10 {
width:100%;
min-height:1px;
margin-top:10px;
margin-bottom:10px;
display:inline-block;
position:relative;
}
Just create a divider class for what ever heights are needed.
Sorry to dig an old grave here, but why not just do this?
<div class="form-group">
</div>
It will add a space the height of a normal form element.
It seems about 1 line on a form is roughly 50px (47px on my element I just inspected). This is a horizontal form, with label on left 2col and input on right 10col. So your pixels may vary.
Since mine is basically 50px, I would create a spacer of 50px tall with no margins or padding;
.spacer { margin:0; padding:0; height:50px; }
<div class="spacer"></div>
My trick. Not elegant, but it works:
<p> </p>
In Bootstrap 4 there are spacing utilites.
Citing the documentation for used notation:
Spacing utilities that apply to all breakpoints, from
xstoxl, have no breakpoint abbreviation in them. This is because those classes are applied frommin-width: 0and up, and thus are not bound by a media query. The remaining breakpoints, however, do include a breakpoint abbreviation.The classes are named using the format
{property}{sides}-{size}forxsand{property}{sides}-{breakpoint}-{size}forsm,md,lg, andxl.Where property is one of:
m- for classes that setmarginp- for classes that setpaddingWhere sides is one of:
t- for classes that setmargin-toporpadding-topb- for classes that setmargin-bottomorpadding-bottoml- for classes that setmargin-leftorpadding-leftr- for classes that setmargin-rightorpadding-rightx- for classes that set both*-leftand*-righty- for classes that set both*-topand*-bottom- blank - for classes that set a
marginorpaddingon all 4 sides of the elementWhere size is one of:
0- for classes that eliminate the margin or padding by setting it to01- (by default) for classes that set themarginorpaddingto$spacer * .252- (by default) for classes that set themarginorpaddingto$spacer * .53- (by default) for classes that set themarginorpaddingto$spacer4- (by default) for classes that set themarginorpaddingto$spacer * 1.55- (by default) for classes that set themarginorpaddingto$spacer * 3
So to have some extra vertical space above and below an element you would use my-5 class.