Jump to content

Changing section background color on hover

Go to solution Solved by creedon,

Recommended Posts

Is it possible to change section background color on hover with smooth transition? In my case, I also have dividers enabled.

I tried targeting all kinds of selectors, but none seems to work.

 

 

Desired effect:
 

Normal:
Screenshot2023-08-09at13_26_53.thumb.png.ceab6015a9aa8248ac500abc3e330fb4.png

 

On hover:

Screenshot2023-08-09at13_27_36.thumb.png.0cf034b32c54bd38521fe5940e15ef2e.png

Edited by pro
Link to comment
1 hour ago, creedon said:

Please see the following for a start on your effect.

Let us know how it goes.

 

Thank you. Almost there except for this weird issue:

When I enter the code in Custom CSS, it gives me Syntax Error on line containing --siteBackgroundColor

 

If you don't mind, one more question about smooth transition. I used the following code:

section[data-section-id="64d3cfe46593f86d84a5243a"]:not(.has-background):hover .section-background {
--siteBackgroundColor: red;
}
section[data-section-id="64d3cfe46593f86d84a5243a"]:not(.has-background) .section-background {
transition: all .5s ease-in-out;
}

Is there a different property I could use instead of all in transition: all .5s ease-in-out?

Thanks.

Edited by pro
Link to comment
Quote

When I enter the code in Custom CSS, it gives me Syntax Error on line containing --siteBackgroundColor

I updated my referenced post. Apparently SS is blocking the use of their CSS variables in the editor.

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
Quote

Is there a different property I could use instead of all in transition: all .5s ease-in-out?

Try...

transition : background-color 0.5s ease-in-out;

after you fix the other 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
1 hour ago, creedon said:

I updated my referenced post. Apparently SS is blocking the use of their CSS variables in the editor.

Thanks so much! Yeah, I've noticed Global CSS blocks the use of variables. But if you use individual page's HTML editor, variables work just fine. Nonetheless, I still replaced --siteBackgroundColor with background-color.

Link to comment
55 minutes ago, pro said:

I've noticed Global CSS blocks the use of variables. But if you use individual page's HTML editor, variables work just fine.

Custom CSS uses the LESS preprocessor, an ancient version from years ago that hasn't kept up with modern CSS standards. The other injection areas do not use LESS.

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
  • 5 months later...

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.