Jump to content

Underline hover animation navigation bar

Recommended Posts

Posted

Site URL: https://www.lucienandsolenn.com/

Hello there! 

I know that there is some post about this, and I found a good code for it . However, I cannot find a way to "stop the line" under the drop down menu links and make it 100% of the word, not beyond. How can I do? I post the picture of it below. Thank you in advance!

My website password : Forthesakeoflove

Here is the css code

.header-nav-item > a:after, .header-nav-folder-item > a:after {
  content:'';
  width: 0px;
  height: 1px;
  background: #fff;
  display: block;
  transition: width .2s ease;
}

.header-nav-item > a, .header-nav-folder-item:hover {
  background: none !important;
}

.header-nav-item--active > a:after, .header-nav-item:hover > a:after, .header-nav-folder-item:hover > a:after {
  width: 100%;
}

.header-nav-folder-item:hover > a {
  color: #fff !important;
} 

Screenshot 2022-09-20 at 11.53.51.png

Posted
3 hours ago, Soona said:

Site URL: https://www.lucienandsolenn.com/

Hello there! 

I know that there is some post about this, and I found a good code for it . However, I cannot find a way to "stop the line" under the drop down menu links and make it 100% of the word, not beyond. How can I do? I post the picture of it below. Thank you in advance!

My website password : Forthesakeoflove

Here is the css code

.header-nav-item > a:after, .header-nav-folder-item > a:after {
  content:'';
  width: 0px;
  height: 1px;
  background: #fff;
  display: block;
  transition: width .2s ease;
}

.header-nav-item > a, .header-nav-folder-item:hover {
  background: none !important;
}

.header-nav-item--active > a:after, .header-nav-item:hover > a:after, .header-nav-folder-item:hover > a:after {
  width: 100%;
}

.header-nav-folder-item:hover > a {
  color: #fff !important;
} 

Screenshot 2022-09-20 at 11.53.51.png

Do you mean something like this?

image.thumb.png.926b65ba4d341d058cd975554ee3d89e.png

BeyondSpace - Squarespace Website Developer

🖼️ Lightbox Studio (Pinch/Zoom images, videos - PDFs Lightbox - ...) </>  🗓️ Delivery Date Picker (Date picker form field)
Gallery block 7.1 workaround </> 🤖 Ask me anything

Posted (edited)

I try the following code and it seems fine

.header-nav-folder-item > a {
  display: inline-block;
}

Let me know how it works on your site

Support me by pressing 👍 if this useful for you

Edited by bangank36

BeyondSpace - Squarespace Website Developer

🖼️ Lightbox Studio (Pinch/Zoom images, videos - PDFs Lightbox - ...) </>  🗓️ Delivery Date Picker (Date picker form field)
Gallery block 7.1 workaround </> 🤖 Ask me anything

  • 1 year later...
Posted

How can I make this work for mobile menu? I have a forced mobile menu on desktop. I tried this code, but the underline animation is across the entire screen.

 

Screenshot2024-02-19at12_27_05AM.thumb.png.3343a8a5f28a9d94e696b5363426f929.png

 

.header-menu-nav-item > a:after, .header-menu-nav-folder-item > a:after {
  content:'';
  width: 0px;
  height: 1px;
  background: #443A31;
  display: block;
  transition: width .5s ease;
}
.header-menu-nav-item > a, .header-menu-nav-folder-item:hover {
  background: none !important;
}
.header-menu-nav-item--active > a:after, .header-menu-nav-item:hover > a:after, .header-menu-nav-folder-item:hover > a:after {
  width: 100%;
}
.header-menu-nav-folder-item:hover > a {
  color: #443A31 !important;
}
body:not(.header--menu-open) .header-menu-nav-item--active>a {
    background-position: 0 calc(~"100% + 1px") !important;
}

 

Posted
On 2/19/2024 at 12:28 PM, JamIsJam88 said:

How can I make this work for mobile menu? I have a forced mobile menu on desktop. I tried this code, but the underline animation is across the entire screen.

 

Screenshot2024-02-19at12_27_05AM.thumb.png.3343a8a5f28a9d94e696b5363426f929.png

 

.header-menu-nav-item > a:after, .header-menu-nav-folder-item > a:after {
  content:'';
  width: 0px;
  height: 1px;
  background: #443A31;
  display: block;
  transition: width .5s ease;
}
.header-menu-nav-item > a, .header-menu-nav-folder-item:hover {
  background: none !important;
}
.header-menu-nav-item--active > a:after, .header-menu-nav-item:hover > a:after, .header-menu-nav-folder-item:hover > a:after {
  width: 100%;
}
.header-menu-nav-folder-item:hover > a {
  color: #443A31 !important;
}
body:not(.header--menu-open) .header-menu-nav-item--active>a {
    background-position: 0 calc(~"100% + 1px") !important;
}

 

You can share link to site where you have problem, we can check 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!)

Posted
On 2/20/2024 at 3:52 AM, tuanphan said:

You can share link to site where you have problem, we can check easier

I was actually able to solve this. Here is the code if anyone else needs a solution.

.header-menu-nav-item>a:hover {
  color: #443A31 !important;
  font-style: italic;
}
@media only screen and (min-width:768px) {
  .header-menu-nav-item > a:after, .header-menu-nav-folder-item > a:after {
    content:'';
    width: 0px;
    height: 1px;
    background: #443A31;
    display: block;
    transition: width 1s ease;
  }
}
@media only screen and (max-width:767px) {
  .header-menu-nav-item > a:after, .header-menu-nav-folder-item > a:after {
    content:'';
    width: 0px;
    height: 1px;
    background: #443A31;
    display: block;
    transition: width 0.25s ease;
  }
}
.header-menu-nav-item > a, .header-menu-nav-folder-item:hover {
  background: none !important;
}
.header-menu-nav-item--active > a:after, .header-menu-nav-item:hover > a:after, .header-menu-nav-folder-item:hover > a:after {
  width: 100%;
}
.header-menu-nav-folder-item:hover > a {
  color: #443A31 !important;
}
body:not(.header--menu-open) .header-menu-nav-item--active>a {
  background-position: 0 calc(~"100% + 1px") !important;
}
.header-menu-nav-item a {
  display: inline-block !important;
}
.header-menu-nav-item {
  text-align: right;
}

 

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.