I have two pictures in a row with img-fluid
class.
They are both of the same width and are taking all the space in the div.
I’m struggling to add space between them.
I have tried 3 things:
-
I’ve added padding-right to the left one and padding-left to the
right one, but it looks bad on a mobile phone when they are each on
a new line (as you would expect). -
I’ve tried to add a third div between them with just a padding, but it ruins the structure.
-
And of course, I’ve tried to give them col-sm-5 instead of col-sm-6, but in that case the gap between them is too big.
How can I add 5-10 pixels between them without ruining other things?
.wrapper {
max-width:500px;
height:500px;
margin:0 auto;
background-color:#f0f0f0;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.4.1/css/bootstrap.css" rel="stylesheet"/>
<div class="wrapper">
<div class="container-fluid">
<div class="row justify-content-between">
<div class="col-sm-6 p-0">
<img src="https://images.pexels.com/photos/912110/pexels-photo-912110.jpeg" class="img-fluid">
</div>
<div class="col-sm-6 p-0">
<img src="https://img.freepik.com/free-photo/white-cloud-blue-sky-sea_74190-4488.jpg" class="img-fluid">
</div>
</div>
</div>
</div>
2
Answers
Here, space between two images and adding multiple same image’s below to show it’s working. I don’t know how much space you want between them.
css code
HTML Code
Use the responsive padding classes (ie:
pr-sm-2
)…https://codeply.com/p/9FeTihZoPs