html - 为什么背景 CSS 颜色不会停留在悬停状态?

标签 html css

在此dev site ,如果您将鼠标悬停在主菜单中的“BRANDS”,它会弹出一个下拉菜单。将鼠标悬停在其中任何一个上,背景闪烁红色然后消失。

我将背景 CSS 添加到主菜单的“li”和“a”元素,如下所示...

.mega-dropdown-inner  ul.level1 li.open:hover{
background: red !important;
}
.mega-dropdown-inner  ul.level1 li a:hover{
background: red;
}

注意:我认为我什至不需要“a”样式,但只是尝试一下以防它有帮助。

知道为什么背景颜色不会在您悬停的整个过程中保持不变吗?

最佳答案

因为这条规则

.t3-megamenu .mega-nav > li a:hover, .t3-megamenu .dropdown-menu .mega-nav > li a:hover, .t3-megamenu .mega-nav > li a:focus, .t3-megamenu .dropdown-menu .mega-nav > li a:focus {
   background-color: #002d5c !important; 
}

在您的 custom.css 行 1031 中。

它覆盖了你的规则

关于html - 为什么背景 CSS 颜色不会停留在悬停状态?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30735908/

相关文章:

html - 我如何将数据传递给 django 布局(如 'base.html' )而不必通过每个 View 提供它?

html - 页脚有问题

html - CSS :active selector

html - 在 firefox 上使用 <li> 元素显示错误

jquery - 使用 jquery 将 onclick 事件添加到音频时间线

javascript - Bootstrap 3 模态 : make it movable/draggable without jquery-ui

jquery - href =""时 HTML <a> 标签的行为

javascript - 如何在使用两个滚动条时将拖动的 div 置于所有内容的顶部?

Javascript - 显示 commandLink 然后消失

css - 在不影响顶部放置的第二个图像的情况下制作图像填充屏幕