Javascript Bootstrap .dropdown li 背景色
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12487707/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Bootstrap .dropdown li background color
提问by PeerPressure
Here is my site: http://defend-foreclosure.com/index.html
这是我的网站:http: //defend-foreclosure.com/index.html
I can't get the list items in the dropdown for "law" to change any color but blue when I hover over them. Can anyone tell me what element in the CSS I need to edit? I've been testing all sorts of elements in both bootstrap.css and bootstrap.min.css with no luck.
当我将鼠标悬停在“法律”的下拉列表中时,我无法将列表项更改为蓝色以外的任何颜色。谁能告诉我需要编辑 CSS 中的哪个元素?我一直在测试 bootstrap.css 和 bootstrap.min.css 中的各种元素,但没有成功。
回答by martincho
Don't change bootstrap.css. Create another css file where you can override this. Anyway, the line is 4572:
不要更改 bootstrap.css。创建另一个 css 文件,您可以在其中覆盖它。无论如何,该行是 4572:
.dropdown-menu li > a:hover, .dropdown-menu li > a:focus, .dropdown-submenu:hover > a
Set background-image to none, and background-color to whatever color you want.
将 background-image 设置为 none,将 background-color 设置为您想要的任何颜色。
回答by Saphired
If you also intend to change the color of a selected element, you should take care of the active class of the li element:
如果您还打算更改所选元素的颜色,则应注意 li 元素的活动类:
.dropdown-menu li.active > a,
.dropdown-menu li.active > a:hover,
.dropdown-menu li.active > a:focus {
...
}