I have a 2 column grid which I want to stack and reverse on mobile. But when doing this the image is not showing up anymore. There is just a white space the size of the image. Here just some snippets from the code
HTML
<section class="grid-middle bg-light flex-flip-sm">
<div class="col-6_sm-12 bg-image img-bar vh-70"></div>
<div class="col-6_sm-12 padded">
<h2 class="heading">Title goes here/h2>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Accusantium illum repudiandae doloribus hic blanditiis nesciunt? Perspiciatis asperiores explicabo vero maiores doloribus. Corporis odit iusto, officia expedita voluptas delectus aperiam aspernatur!</p>
</div>
</section>
CSS
.flex-flip-sm{
display:flex;
flex-direction:column-reverse;
}
This is what it looks like, just the white space the size as the image should be.
Tried adding min-height, padding, etc but nothing works.
2
Answers
The background image may not be visible due to how the background-image property is being applied.
Instead of using the background-image property, you can try using an
img
tag within the.bg-image
container. This way, the image will be part of the HTML content, and it will be easier to control the sizing and positioning.HTML
CSS
This should ensure that the image is displayed properly on mobile devices when the flex container is stacked and reversed.
You should add a width and height to see your image.
See the code below :