Jump to content

Exclude Blog Post Pages from Custom CSS

Go to solution Solved by Lesum,

Recommended Posts

Posted

Hi,

Thanks in advance for your help.

I have custom code injected on my site so that the header for each site page is different on desktop and mobile. 

The problem is that I would like to start posting blog content, and the code I used is making it so that the blog post content isn't visible on mobile devices. 

The site url is https://poze.app

The code I used is: 

<style>
@media only screen and (max-width: 780px) {
    #page section:nth-of-type(1) { 
            display: none; 
    } 
  }
@media only screen and (min-width: 781px) {  
    #page section:nth-of-type(2) { 
        display: none !important;
    }
  }
   @media only screen and (min-width: 781px) {  
    #page section:nth-of-type(3) { 
        display: none !important;
    }
  }

Is it possible to exempt all blog post pages from this code injection? 

Thanks. 

  • Solution
Posted (edited)

Hi, first remove "!important" from your code in custom css. Then after going to blog > advanced > page Header Code Injection, you can insert this code:

<style>
@media only screen and (max-width: 780px) {
    #page section:nth-of-type(1) { 
            display: block !important; 
    } 
}
@media only screen and (min-width: 781px) {  
    #page section:nth-of-type(2) { 
        display: block !important;
    }
}
@media only screen and (min-width: 781px) {  
    #page section:nth-of-type(3) { 
        display: block !important;
    }
}
</style>

It should exclude the custom css from blog posts. 

Edited by Lesum

If my comments were useful, please like or mark my solution as answer so others can scroll to it quickly. 

Sam
Web Developer & Digital Designer

 Did you find my contribution helpful? Buy me a coffee?

Create an account or sign in to comment

You need to be a member in order to leave a comment

×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.