I'm struggling to display one image per row on smaller screens using the sm
breakpoint.
This is my first attempt at using bootstrap 4. I followed their grid system guidelines which stated that responsive breaks occur when specifying a size for each col-
class. However, I am not seeing any changes in the layout.
From a large screen:
https://i.sstatic.net/DmZjN.png
To a smaller screen:
https://i.sstatic.net/n9O2K.png
HTML
<div class="container-fluid text-right">
<div class="row">
<div class="col-sm-12 col-md-6">
<div class="card mb-3">
<div class="card-img"
style="background-image:url(https://snap-photos.s3.amazonaws.com/img-thumbs/960w/1U2EGZ07GU.jpg);">
</div>
<div class="card-img-overlay d-flex flex-column justify-content-between">
<h4 class="card-title">das das</h4>
<p class="card-text">lorem oirrwerwer asdf asfd</p>
</div>
</div>
</div>
<div class="col-sm-12 col-md-6">
<div class="card mb-3">
<div class="card-img"
style="background-image:url(https://snap-photos.s3.amazonaws.com/img-thumbs/960w/1U2EGZ07GU.jpg);">
</div>
<div class="card-img-overlay d-flex flex-column justify-content-between">
<h4 class="card-title">das das</h4>
<p class="card-text">lorem oirrwerwer asdf asfd</p>
</div>
</div>
</div>
</div>
</div>
CSS
.card {
width: 100%;
height: 300px;
overflow: hidden;
}
.card-img {
width: 100%;
height: 100%;
object-fit: cover;
background-color: black; /* fallback color */
background-position: center;
background-size: cover;
transition:all 0.3s ease-in-out;
opacity:1;
}
.card:hover .card-img,
.card:focus .card-img {
transform: scale(1.2);
opacity:0.5;
}
.card:hover .card-img-overlay{
color:#730d0d;
}
.card-img-overlay>h4, .card-img-overlay>p{
visibility:hidden;
}
.card-img-overlay:hover h4, .card-img-overlay:hover p{
visibility: visible;
}
.card:hover .card-img-overlay p{
}