Problems with navbar link styling

Hi,

I try to design my links in the navbar. But I have a mistake somewhere and I can’t find it. Can anyone help?

This is the code in the header section:

<style>
.nav-item a.nav-link {
  padding: 0 0 5px;
  color: white !important;
}
.nav-item a.nav-link:before {
  content: "";
  position: absolute;
  width: 100%;
  height: 2px;
  bottom: 0;
  left: 0;
  background-color: #FFF;
  visibility: hidden;
  transform: scaleX(0);
  transition: all 0.3s ease-in-out;
}
.nav-item a.nav-link:hover:before ,
.nav-item a.nav-link:focus:before  {
  visibility: visible;
  transform: scaleX(1);
}
</style>

But the whole navbar is underlined when hovering instead of the word “Home” :pensive:

The easiest way is to set the menu to none. Then just create a custom class and you can style the nav links any way you want.

Casey

Do you mean changing to that?

Bildschirmfoto 2020-05-06 um 13.46.15

Yes, that’s correct.
Then click on one menu item.
CleanShot 2020-05-06 at 07.51.34@2x

Create a class and style it. You have to apply it to all the links in the menu.

CleanShot 2020-05-06 at 07.51.43@2x

Casey

This does not work :pensive: ich habe es probiert. But the line below, when i hover, stays over the entire width of the nav bar.

I think that’s your opinion. I’ll stay out of your forum.

Casey

Yeah you are right, I apologise for my bad wording.

Update: Now I have actually had some sleep… Your method does work, and I am always open to suggestions on improving workflow, however you will still need to add code to the page header to achieve the effect the OP was after, since the class manager doesn’t, at present support all of the styles needed.

One solution is adding one extra line position: relative; to the existing code with the default classes.

I personally think this approach is easier.

If you are interested… adding to the manager a class called

navbar-nav li a

will style the menu links without having to add classes to every item. Blocs will add this class to the manager if you edit the navigation link text in the project settings.

mhm … unfortunately I can’t solve my problem with the previous tips

Hey @mr_xing,

Give this a try, its working in my test project

<style>
.nav-item a.nav-link{
  padding: 0 0 5px;
  color: #fff!important;
  position: relative;	
}
.nav-item a.nav-link::before {
  content: "";
  position: absolute;
  width: 100%;
  height: 2px;
  bottom: 0;
  left: 0;
  background-color: #FFF;
  transform: scaleX(0);
  transition: all 0.3s ease-in-out;
}
.nav-item a.nav-link:hover::before,
.nav-item a.nav-link:focus:before  {
  transform: scaleX(1);
}
</style>

Yes Man, that worked like a charme for me!

Thanks a lot :+1:t3: and stay healthy

1 Like

Great, you too mate.