Jump to content

[Share] Hover Navigation Link - Change Page Background

Recommended Posts

#1. Suppose you have 4 navigation items with urls

  • Pricing - /pricing
  • Services - /services
  • About - /about
  • Contact  - /contact

when hover on each item >> will change page background color

#2. You can use this code to Website > Website Tools > Custom CSS

/* Pricing */
body:has(div.header-nav-item a[href="/pricing"]:hover) {
  .section-background, .section-border {
    background-color: transparent !important;
}
  section {
    background-color: #000 !important;
  }
}
/* Services */
body:has(div.header-nav-item a[href="/services"]:hover) {
  .section-background, .section-border {
    background-color: transparent !important;
}
  section {
    background-color: #f0f !important;
  }
}
/* About */
body:has(div.header-nav-item a[href="/about"]:hover) {
  .section-background, .section-border {
    background-color: transparent !important;
}
  section {
    background-color: green !important;
  }
}
/* Contact */
body:has(div.header-nav-item a[href="/contact"]:hover) {
  .section-background, .section-border {
    background-color: transparent !important;
}
  section {
    background-color: red !important;
  }
}

image.thumb.png.9cdce0002368f16b12cf3df4b8afe34f.png

#3. To change Page text color, you can add this line, for example Pricing code, it will be

/* Pricing */
body:has(div.header-nav-item a[href="/pricing"]:hover) {
  .section-background, .section-border {
    background-color: transparent !important;
}
  section {
    background-color: #000 !important;
  }
  /* text color */
  section * {
      color: #fff !important;
  }
}

 

Edited by tuanphan

Email me if you have need any help (free, of course.). Answer within 24 hours. 
Or send to forum message

Contact Customer Care - Learn CSS - Buy me a coffee (thank you!)

Link to comment
  • Replies 0
  • Views 126
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Posted Images

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.