So I have an image that I want to set as the background. On top of that image, I’d like to be able to use Bootstrap’s grid. Here’s the code I have so far:
HTML
<div class="container">
<img src="..." alt="Background image">
<div class="row">
<div class="col">
<!-- An image -->
</div>
<div class="col">
<!-- Text -->
</div>
<div class="col">
<!-- Text -->
</div>
</div>
<div class="row">
<!-- ... -->
</div>
<!-- More rows -->
</div>
CSS
.container{
width: 100%;
}
.container img {
object-fit: cover;
width: 100%;
}
Edit:
I should mention that the only way I can access the image is in the HTML. I’m developing a Shopify theme, so to get the image I do:
<img src="{{ section.settings.image | img_url:'master' }}" alt="Background image">
So using
background-image: url(...);
doesn’t work in my case as I don’t know the path.
2
Answers
You could pass image as background image for the container.
Or you can implement this style to the image.