我试图在悬停/聚焦时更改字形图标的背景颜色,但在我的横幅中没有成功。下面是 2 个字形图标的代码片段,即 glyphicon-user 和 glyphicon -登录。即使我在 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/