Reputation: 32558
Is there a way to add some space between the div with H3-1
and the div containing H3-2
.
CSS
would be preferable but it is not necessary.col-sm-6
because using col-sm-5
and offset
adds more space than what I want.ml-auto
and mr-auto
is also important because sometimes there can be odd number of columns (which comes in dynamically) and it needs to be centered.@import url(https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css);
<div class="container">
<div class="row row-eq-height">
<div class="col-sm-6 border align-top ml-auto mr-auto mt-3 bg-light">
<div class="m-0 p-2">
<h3>H3-1</h3>
<p>sad ajsdha sjhd ajshdjashd jashdj ashdj ashd jashd jashdj ashdj ashdj ashdj ashdjas dashdj asdhjashd ashd as</p>
</div>
</div>
<div class="col-sm-6 border align-top ml-auto mr-auto mt-3 bg-light">
<div class="m-0 p-2">
<h3>H3-2</h3>
<p>asjd asjdh asjdhasj hasjdh jshd jashjas dh jasdha jdh jashdj ashdj shdj ashdj </p>
</div>
</div>
<div class="col-sm-6 border align-top ml-auto mr-auto mt-3 bg-light">
<div class="m-0">
<h3>H3-3</h3>
<p>asd asd asd a</p>
</div>
</div>
</div>
</div>
Upvotes: 4
Views: 254
Reputation: 32558
@import url(https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css);
<div class="container">
<div class="row row-eq-height">
<div class="col-sm-6 align-top ml-auto mr-auto mt-3 p-0">
<div class="border border-primary rounded ml-1 mr-1 h-100 p-2 bg-light">
<h3>H3-1</h3>
<p>sad ajsdha sjhd ajshdjashd jashdj ashdj ashd jashd jashdj ashdj ashdj ashdj ashdjas dashdj asdhjashd ashd as</p>
</div>
</div>
<div class="col-sm-6 align-top ml-auto mr-auto mt-3 p-0">
<div class="border border-primary rounded ml-1 mr-1 h-100 p-2 bg-light">
<h3>H3-2</h3>
<p>asjd asjdh asjdhasj hasjdh jshd jashjas dh jasdha jdh jashdj ashdj shdj ashdj </p>
</div>
</div>
<div class="col-sm-6 align-top ml-auto mr-auto mt-3 p-0">
<div class="border border-primary rounded ml-1 mr-1 h-100 p-2 bg-light">
<h3>H3-3</h3>
<p>asd asd asd a</p>
</div>
</div>
</div>
</div>
Upvotes: 0
Reputation: 894
[Not relevant anymore] Yes, for example, by changing column classes from col-sm-6
to col-sm-5
and adding col-md-offset-2
class to second column:
[Edited example to reflect edits in question: ]
<!DOCTYPE html>
<html lang="en-us">
<head>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
</head>
<div class="container">
<div class="row row-eq-height">
<div class="col-sm-6 align-top ml-auto mr-auto mt-3 pl-1 pr-1">
<div class="h-100 bg-light border m-0 p-2 pl-4 pr-4">
<h3>H3-1</h3>
<p>sad ajsdha sjhd ajshdjashd jashdj ashdj ashd jashd jashdj ashdj ashdj ashdj ashdjas dashdj asdhjashd ashd as</p>
</div>
</div>
<div class="col-sm-6 align-top ml-auto mr-auto mt-3 pl-1 pr-1">
<div class="h-100 bg-light border m-0 p-2 pl-4 pr-4">
<h3>H3-2</h3>
<p>asjd asjdh asjdhasj hasjdh jshd jashjas dh jasdha jdh jashdj ashdj shdj ashdj </p>
</div>
</div>
<div class="col-sm-6 align-top ml-auto mr-auto mt-3 pl-1 pr-1">
<div class="h-100 bg-light border m-0 p-2 pl-4 pr-4">
<h3>H3-3</h3>
<p>asjd asjdh asjdhasj hasjdh jshd jashjas dh jasdha jdh jashdj ashdj shdj ashdj </p>
</div>
</div>
</div>
</div>
</html>
Upvotes: 1
Reputation: 116
I'm not sure why you are not able to add custom CSS but I managed to add some space using bootstrap 4's flex layouts.
<head>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
</head>
<div class="container">
<div class="flex-row row-eq-height d-inline-flex">
<div class="col-sm-6 border align-top mt-3 bg-light mr-2">
<div class="m-0 p-2">
<h3>H3-1</h3>
<p>sad ajsdha sjhd ajshdjashd jashdj ashdj ashd jashd jashdj ashdj ashdj ashdj ashdjas dashdj asdhjashd ashd as</p>
</div>
</div>
<div class="col-sm-6 border align-top mt-3 bg-light ml-2">
<div class="m-0 p-2">
<h3>H3-2</h3>
<p>asjd asjdh asjdhasj hasjdh jshd jashjas dh jasdha jdh jashdj ashdj shdj ashdj </p>
</div>
</div>
</div>
</div>
you can increase/decrease mr-2/ml-2 to increase the left and right margins on your bootstrap columns as you see fit
Upvotes: 0