Jump to content

How to add a hover effect to two button in navigation menu

Recommended Posts

Posted

I want my header to have two buttons, and currently I have this code working well except that it doesn't have a hover effect. Does anyone know how I can add a change of colour on hover? 

.header-nav-item:nth-child(5) a, {
  background: #0092b3 !important;
  color: #FFFFFF !important;
  width: 160px;
  letter-spacing: 0.2em;
  font-weight: 700 !important;
  border-radius: 0px;
  text-align: center !important;
}

.header-nav-item:nth-child(6) a, {
  background: #0092b3 !important;
  color: #FFFFFF !important;
  width: 160px;
  letter-spacing: 0.2em;
  font-weight: 700 !important;
  border-radius: 0px;
  text-align: center !important;
}

temp-vet.jpg

Posted

Hi , try this edit to your CSS:

.header-nav-item:nth-child(5) a {
  background: #0092b3 !important;
  color: #FFFFFF !important;
  width: 160px;
  letter-spacing: 0.2em;
  font-weight: 700 !important;
  border-radius: 0px;
  text-align: center !important;
  transition:ease-in-out 300ms;
  &:hover {
   background: #000000 !important;
  }
}

.header-nav-item:nth-child(6) a {
  background: #0092b3 !important;
  color: #FFFFFF !important;
  width: 160px;
  letter-spacing: 0.2em;
  font-weight: 700 !important;
  border-radius: 0px;
  text-align: center !important;
  transition:ease-in-out 300ms;
  &:hover {
   background: #000000 !important;
  }
}

Adjust the background color and transition time to suit your design and preference. You can also add an new property within the &:hover{} if you want to have more transition changes to the button style.

Please let me know if this worked, and upvote if this was helpful!

Please like and upvote if my comments were helpful to you. Cheers!

Zygmunt Spray
Squarespace Website Designer
Contact me: 
https://squarefortytwo.com 
Hire me on Upwork!

📈 SEO Space (Referral link)
Ⓜ️ 
Will Myers' Plugins & Tutorials (Referral link)
 🔌 Ghost Squarespace Plugins (Referral link)
 SquareWebsites Plugins (Referral link)
 🔲SQSP Themes (Referral link) 
Spark Plugin (Referral link) 
 🖼️Pinch-to-Zoom Gallery Lightbox Plugin (Referral link) 

 Did I help? Buy me a coffee?

Posted
On 9/15/2022 at 8:16 AM, tld said:

I want my header to have two buttons, and currently I have this code working well except that it doesn't have a hover effect. Does anyone know how I can add a change of colour on hover? 

.header-nav-item:nth-child(5) a, {
  background: #0092b3 !important;
  color: #FFFFFF !important;
  width: 160px;
  letter-spacing: 0.2em;
  font-weight: 700 !important;
  border-radius: 0px;
  text-align: center !important;
}

.header-nav-item:nth-child(6) a, {
  background: #0092b3 !important;
  color: #FFFFFF !important;
  width: 160px;
  letter-spacing: 0.2em;
  font-weight: 700 !important;
  border-radius: 0px;
  text-align: center !important;
}

temp-vet.jpg

It looks like this code will work on Desktop only, if it doesn't on mobile, you can share site url, we can help easier

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!)

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.