Shopify themes, liquid, logos, and UX
We're moving the community! Starting July 7, the current community will be read-only for approx. 2 weeks. You can browse content, but posting will be temporarily unavailable. Learn more
Hello, I’m having a bit of trouble coloring the white background to the left and right of the banner image. I’d like the areas beside the banner to be black, and I’ve tried to achieve this with CSS, but it only turns the entire banner and its sides into one solid black section. It seems the background color is being applied over the image, completely covering it rather than sitting behind it. I don’t want to stretch the image to cover the sides—I’d like to keep its original dimensions and aspect ratio. If anyone more skilled than me could find a solution, I’d really appreciate it.
https://doftnoter.se/collections/valentino
Passw: test12345
Thanks!
Solved! Go to the solution
This is an accepted solution.
You can achieve this by wrapping your banner image in a full-width container with a black background, and centering the image inside it without stretching. Make sure the image itself isn’t set to 100% width if you want to maintain its original aspect ratio.
.custom-banner-wrapper {
background-color: black;
text-align: center;
padding: 20px 0; /* optional vertical spacing */
}
.custom-banner-wrapper img {
display: inline-block;
max-width: 100%;
height: auto;
}
This is an accepted solution.
You can achieve this by wrapping your banner image in a full-width container with a black background, and centering the image inside it without stretching. Make sure the image itself isn’t set to 100% width if you want to maintain its original aspect ratio.
.custom-banner-wrapper {
background-color: black;
text-align: center;
padding: 20px 0; /* optional vertical spacing */
}
.custom-banner-wrapper img {
display: inline-block;
max-width: 100%;
height: auto;
}
Good idea, it works fine. Thanks!
Hi @entranced
I see you have already made it full-width.
- Helpful? Like & Accept solution!
- Ryviu - Product Reviews & QA app: Collect customer reviews, import reviews from AliExpress, Amazon, Etsy, Walmart, Dhgate and CSV.
- Lookfy Gallery: Lookbook Image - Gain customers with photo gallery, video & shoppable image.
- Reelfy‑Shoppable Videos+Reels: Create shoppable videos to engage customers and drive more sales.
- Enjoy 1 month of Shopify for $1. Sign up now.