简体   繁体   English

如何从Bootstrap主题中移除悬停导航下划线?

[英]How do I remove nav underline on hover from Bootstrap theme?

I went into the css and removed all of the text-decoration:underline but for some reason it's still showing up. 我进入CSS并删除了所有text-decoration:underline,但是由于某种原因,它仍然显示出来。 Can somebody please tell me how to remove the top navigation underline when you hover over the nav? 悬停在导航上方时,有人可以告诉我如何删除顶部导航下划线吗?

Here is a link to the Oleose theme. 这是油腻主题的链接。

http://www.scoopthemes.com/templates/Oleose/Freeze/ http://www.scoopthemes.com/templates/Oleose/Freeze/

Here is the culprit. 这是罪魁祸首。 It's a pseudo-element (:after) that makes the underline under the link. 这是一个伪元素(:after),在链接下划线。

header .navbar-default ul.navbar-nav li a:hover:after {
  background: #ffffff;
}

Just remove this or set background to transparent. 只需删除它或将背景设置为透明即可。 Or even better remove this one too. 甚至最好也删除这一部分。

header .navbar-default ul.navbar-nav li a:after{
    ....
}

Here is the style made for the underline. 这是为下划线设计的样式。

So you understand what's going on there: The "underline" you are referring to is created as a pseudo element :after on the link itself. 因此,您了解那里发生了什么:您所指的“下划线”在链接本身上被创建为伪元素:after It is even there if you do not mouseover the link, it's just that in that state it has a transparent background-color so you cannot see it. 即使不将鼠标悬停在链接上,它也在那里,只是在这种状态下它具有透明的背景色,所以您看不到它。 On :hover the background-color of this pseudo element is changed to #ffffff and thus the element becomes visible. :hover上,此伪元素的背景色更改为#ffffff ,因此该元素变为可见。 This is done in a transition fashion so it doesn't change abruptly, but softly. 这是以过渡方式完成的,因此它不会突然但轻柔地变化。

This is the rule that makes the "underline" visible: 这是使“下划线”可见的规则:

header .navbar-default ul.navbar-nav li a:hover:after {
    background: #ffffff;
}

If you change it to 如果您将其更改为

header .navbar-default ul.navbar-nav li a:hover:after {
    background-color: transparent;
}

it will stay invisible also when :hover happens. :hover发生时,它也将保持不可见。 And you can always go there later and reactivate it if necessary! 而且,您以后总是可以去那里,并在必要时将其重新激活!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM