twitter-bootstrap 如何从 twitter bootstrap 按钮下拉菜单上的列表项中删除背景颜色?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13784700/
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
How to remove background color from list items on a twitter bootstrap button dropdown menu?
提问by nabucosound
I am struggling with the button dropdowns, I cannot remove the blue background color that appears when hovering through the menu list items. I tried changing the a:hover CSS but with no success. Maybe this background color is dinamically added with javascript?
我在按钮下拉菜单中苦苦挣扎,无法删除悬停在菜单列表项中时出现的蓝色背景色。我尝试更改 a:hover CSS,但没有成功。也许这个背景颜色是用javascript动态添加的?
Thanks!
谢谢!
Edit:
编辑:
I tried this code and no success:
我试过这段代码,但没有成功:
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="utf-8">
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.2.2/css/bootstrap-combined.min.css" rel="stylesheet">
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.js"></script>
</head>
<body>
<style type="text/css" media="screen">
.dropdown > li > a:hover {
background-color: transparent;
}
</style>
<div class="btn-group">
<a class="btn dropdown-toggle" data-toggle="dropdown" href="#">
Action
<span class="caret"></span>
</a>
<ul class="dropdown-menu">
<li><a href="#">link me</a></li>
<li><a href="#">link me too</a></li>
</ul>
</div>
<script src="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.2.2/js/bootstrap.min.js"></script>
</body>
</html>
It looks like the CSS background color is not applied to the element. Why?
看起来 CSS 背景颜色没有应用于元素。为什么?
回答by theClap
This should work
这应该工作
.dropdown-menu li a:hover :focus {
color:black;/*color turns white if not changed*/
background: none;
}

