Jump to content

Underline hover animation navigation bar

Recommended Posts

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

Link to comment
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 (Enable Pinch/Zoom on lightbox)
🗓️ Delivery Date Picker (Squarespace Date picker form field)
💫 Gallery block 7.1 workaround
🥳 Sparkplugin Customisations Browsers (Browse +100 Spark plugin customisations)
🥳 Elfsight Template Browsers (Browse +1000 Elfsight widget Templates)

If you find my answer useful, let's leave a like or upvote so others with the same issue can find their solution. Thank you!

 

Link to comment

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 (Enable Pinch/Zoom on lightbox)
🗓️ Delivery Date Picker (Squarespace Date picker form field)
💫 Gallery block 7.1 workaround
🥳 Sparkplugin Customisations Browsers (Browse +100 Spark plugin customisations)
🥳 Elfsight Template Browsers (Browse +1000 Elfsight widget Templates)

If you find my answer useful, let's leave a like or upvote so others with the same issue can find their solution. Thank you!

 

Link to comment
  • 1 year later...

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;
}

 

Link to comment
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!)

Link to comment
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;
}

 

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.