I have two rows, each one of them divided into 2 columns with col-sm-6
. As long as I keep the code as it is, the columns work, but the sections are all sticking together; so, when i try to give them some margin by setting
.col-sm-6 {
margin: 15px;
}
in the CSS, the columns break and get all divided vertically. No matter what kind of margin I put, it will always give me the same problem. I tried some other possible solutions beside this, but still, I can't solve it. What am i doing wrong?
<div class="container">
<div class="row">
<div class="col-sm-6 categories" style="background-image: url(https://source.unsplash.com/category/nature/1600x900);">
<div class="opacity-overlay">
<h2>Section 1</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit.</p>
</div>
</div>
<div class="col-sm-6 categories" style="background-image: url(https://source.unsplash.com/category/food/1600x900);">
<div class="opacity-overlay">
<h2>Section 2</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit.</p>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-6 categories" style="background-image: url(https://source.unsplash.com/category/people/1600x900);">
<div class="opacity-overlay">
<h2>Section 3</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit.</p>
</div>
</div>
<div class="col-sm-6 categories" style="background-image: url(https://source.unsplash.com/category/Objects/1600x900);">
<div class="opacity-overlay">
<h2>Section 4</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit.</p>
</div>
</div>
</div>
</div>
This is the CSS:
.categories {
text-align: center;
background-position: center center;
background-size: cover;
color: black;
padding: 50px;
}
.opacity-overlay {
background: rgba(255, 255, 255, 0.85);
padding: 1px 20px 10px 20px;
}