Jump to content

Target specific type of section with code injection

Recommended Posts

Hi all,

Is it possible to target code injections so they only run if certain conditions are true? For example, I pieced together this code for centering list items:

<style>
  .user-items-list-simple {
    justify-content: center;
    display: flex !important;
    flex: 1 1 0px
    flex-flow: row nowrap;
}
</style>

<style>
  .list-item {
    display: flex;
    flex-flow: column nowrap;
    flex: 1 1 0px;
    max-width: 15%;
    height: auto;
    margin: 0 auto;
</style>

But would like it to only target either lists without a button, or only list items with a button that says "Read Bio". 

Any help would be greatly appreciated. Thanks!!

Link to comment
  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Without being able to see the context of everything it is hard to say for sure. I think the kind of logic you are looking for isn't possible with CSS. CSS is kind of like a hierarchy and deeper elements can't effect elements higher up.

For the kind of effect you want you would need Javascript. The Javascript could check for the existence of an element and then apply a custom class to turn on your effect.

Using Javascript requires the business plan or above.

Edited by creedon

Find my contributions useful? Please like, upvote, mark my answer as the best ( solution ), and see my profile. Thanks for your support! I am a Squarespace ( and other technological things ) consultant open for new projects.

Link to comment
3 hours ago, creedon said:

@dl_23

Without being able to see the context of everything it is hard to say for sure. I think the kind of logic you are looking for isn't possible with CSS. CSS is kind of like a hierarchy and deeper elements can't effect elements higher up.

For the kind of effect you want you would need Javascript. The Javascript could check for the existence of an element and then apply a custom class to turn on your effect.

Using Javascript requires the business plan or above.

Thanks for your response @creedon! I am completely unfamiliar with Javascript... Do you happen to know the code/functions I would use, or have an idea of where I could learn?

Thanks!

Link to comment

Please post the URL for a page on your site where we can see your issue. I think you've described what you want to accomplish well so it's just a matter of seeing if Javascript can get you the rest of the way to your desired effect.

If your site is not public please set up a site-wide password, if you've not already done so.

Post the password here.

Adding a site-wide password is not a security breach. Please read the documentation at the link provided to understand how it works.

Please read the documentation at the link provided on how to share a link to your site to understand how it works. A link to the backend of the your site won’t work for us, i.e. a url that contains /config/.

We can then take a look at your issue.

Find my contributions useful? Please like, upvote, mark my answer as the best ( solution ), and see my profile. Thanks for your support! I am a Squarespace ( and other technological things ) consultant open for new projects.

Link to comment

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.