FROM CACHE - en_header

Adding background image to homepage only (re: Dawn theme)

Solved
kmjames
Tourist
7 0 1

Hello. In an effort to add a background image to my homepage I added the code below to base.css. It appears exactly as I want it to but because I used the Main Content ID it applies to every page. Ideally this would only apply to the homepage but my CSS knowledge was overwritten by random useless knowledge many years ago. Any assistance would be most appreciated.

 

The site: https://yoxcheevpdzsoe8n-56120737892.shopifypreview.com/

Password: sowdea

 

The code I used:

#MainContent{
background-image: url(https://cdn.shopify.com/s/files/1/0561/2073/7892/files/background-02.jpg?v=1641067730);
background-size: cover;
background-position: center;
background-attachment: fixed;
}

Much thanks in advance!

 

Kevin

Accepted Solution (1)

Accepted Solutions
digitsupCA
Shopify Partner
188 12 40

This is an accepted solution.

@kmjames add below code on theme.liquid file 

{% if template contains 'index' %}
<style>
#MainContent {
    background-image: url(https://cdn.shopify.com/s/files/1/0561/2073/7892/files/background-02.jpg?v=1641067730);
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
}
</style>
{% endif %}
- Did we solve your issue? Like & Mark As Solution to help the community

Should you need any direct help: https://www.upwork.com/freelancers/~01f7c2b0b17e9c9b8d

View solution in original post

Replies 4 (4)
digitsupCA
Shopify Partner
188 12 40

This is an accepted solution.

@kmjames add below code on theme.liquid file 

{% if template contains 'index' %}
<style>
#MainContent {
    background-image: url(https://cdn.shopify.com/s/files/1/0561/2073/7892/files/background-02.jpg?v=1641067730);
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
}
</style>
{% endif %}
- Did we solve your issue? Like & Mark As Solution to help the community

Should you need any direct help: https://www.upwork.com/freelancers/~01f7c2b0b17e9c9b8d
kmjames
Tourist
7 0 1

@digitsupCA that worked perfectly. Thank you so much!

Ogltz
Tourist
5 0 2

It did not workout help me please thanks.

 

xvfbe
New Member
1 0 0

i think it isnt working anymore with dawn theme