html - 在 Bootstrap 中更改字形图标的背景颜色

标签 html css twitter-bootstrap

我试图在悬停/聚焦时更改字形图标的背景颜色,但在我的横幅中没有成功。下面是 2 个字形图标的代码片段,即 glyphicon-userglyphicon -登录。即使我在 css 中设置了另一种颜色,背景也会变为白色。

1.html

<div class="row">
<div class="col-sm-6 col-md-offset-4 col-md-4">
  <a id="logo" href="#"> <img src="../static/images/logo_small.png" data-medium="../static/images/logo_medium.png" data-large="../static/images/logo_large.png"></a>
</div>
<div class="col-sm-6 col-md-4">
  <ul class="nav navbar-nav pull-right">
    <li><a class="custom-white" href="#"><span class="glyphicon glyphicon-user"></span> Sign Up</a></li>
    <li><a class="custom-white" href="#"><span class="glyphicon glyphicon-log-in"></span> Login</a></li>
  </ul>
</div>

2.css

.custom-white { color:#fff;}

.custom-white:hover, 
.custom-white:active,
.custom-white:focus {background-color: yellow;}

最佳答案

在属性值之后添加 !important

工作 demo

.custom-white:hover, 
.custom-white:active,
.custom-white:focus {background-color: yellow !important;}

关于html - 在 Bootstrap 中更改字形图标的背景颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28612349/

相关文章:

css - Angular Material 和 layout-fill 最多可填充 100% 的屏幕,仅此而已

HTML、CSS 响应式流体布局元素

javascript - 在动态 html 中呈现外部、内部、内联 css 样式之间的区别

twitter-bootstrap - 在 BootStrap Container Dive 中将 .well Div 居中

javascript - Onsubmit 不起作用

javascript - 最小的 jQuery 模板

javascript - 固定按钮在滚动后停止工作

javascript - 使用转换 :translate on parent 时固定元素出现问题

javascript - 更改 Bootstrap 模式选项一旦存在

javascript - 在 Bootstrap 框架中隐藏/显示元素