Have your say in Community Polls: What was/is your greatest motivation to start your own business?

Re: Change only the mobile background gradient

Solved

Change only the mobile background gradient

GLL2024
Tourist
5 0 2

Currently I've solutioned a background image using the following code in the Custom CSS for various sections for desktop viewing:

.gradient {
  background: var(--gradient-background);
  background-attachment: scroll;
  background-image: url(https://cdn.shopify.com/s/files/1/0606/5707/4263/files/Gradient_Checker_Background.jpg) !important;
  background-color: transparent !important;
  background-position: center !important;
  background-size: cover !important;
  background-repeat: no;
}

However because this is a wide image, I would like to add an alternate image for the background when viewing on mobile. https://cdn.shopify.com/s/files/1/0606/5707/4263/files/Gradient_Checker_Background_mobile.jpg 

Example: Great Lakes Littles Branding Homepage Mobile.jpg

1. Is there a better/easier way for me to apply background images to all of my pages?

2. How do I change the background image for mobile only?

 

Website: greatlakeslittles.com

Password: mitten

Accepted Solution (1)

devcoders
Shopify Partner
564 79 141

This is an accepted solution.

Hello @GLL2024 

 

Go to Online Store, then Theme, and select Edit Code.
Search for assets/base.css.
Add the provided code at the end of the file.

 

@media screen and (max-width: 750px) {
     .gradient {
  background-image: url(https://cdn.shopify.com/s/files/1/0606/5707/4263/files/Gradient_Checker_Background.jpg)!important;
}
}
Shopify Developer: Helping eCommerce Stores

If you need assistance with your store, feel free to contact us at devcodersp@gmail.com
WhatsApp No: +91 8516919310 If my assistance was helpful, please consider liking and accepting the solution. Thank you!

View solution in original post

Replies 2 (2)

Tech_Coding
Shopify Partner
417 110 98

You can add code by following these steps

1. Go to Online Store -> Theme -> Edit code.
2. Open your theme.liquid file

3. Paste the below code before </body> on theme.liquid
<style>
@media (max-width: 767px) {
   .gradient { 
       background-image: https://cdn.shopify.com/s/files/1/0606/5707/4263/files/Gradient_Checker_Background_mobile.jpg !important;
   }
}
</style>
my reply helpful? Click Like to let me know!
your question answered? Mark it as an Accepted Solution.

my reply helpful? Click Like to let me know!
your question answered? Mark it as an Accepted Solution.
Shopify UI Developer
Your Coffee Tips adds a little sweetness to my day.

devcoders
Shopify Partner
564 79 141

This is an accepted solution.

Hello @GLL2024 

 

Go to Online Store, then Theme, and select Edit Code.
Search for assets/base.css.
Add the provided code at the end of the file.

 

@media screen and (max-width: 750px) {
     .gradient {
  background-image: url(https://cdn.shopify.com/s/files/1/0606/5707/4263/files/Gradient_Checker_Background.jpg)!important;
}
}
Shopify Developer: Helping eCommerce Stores

If you need assistance with your store, feel free to contact us at devcodersp@gmail.com
WhatsApp No: +91 8516919310 If my assistance was helpful, please consider liking and accepting the solution. Thank you!