html - 如何更改按钮悬停属性中的文本颜色

标签 html css twitter-bootstrap button hover

我使用本指南在我使用 bootstrap 制作的网页中自定义按钮:

Change hover color on a button with Bootstrap customization

问题是我无法在悬停时保持相同的字体颜色,而且我无法解释为什么它总是变为深灰色。 这是代码:http://codepen.io/anon/pen/ByKZZK

HTML:

<head>
   <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
</head>

<button href="mailto:abc@def.ghi" class="btn btn-custom btn-lg btn-block">info@mail.org&nbsp; <span class="glyphicon glyphicon-envelope"></span></button>

CSS:

.btn-custom {
    color: #FFD180;;
    background-color: #483737;
    border-color: #357ebd; /*set the color you want here*/
}
.btn-custom:hover, .btn-custom:focus, .btn-custom:active, .btn-custom.active, .open>.dropdown-toggle.btn-custom {
    color: #FFD180;
    background-color: #837171;
    border-color: #837171; /*set the color you want here*/
}

有什么想法吗?

最佳答案

只需将 !important; 添加到 CSS 的 hover 部分的 color: #FFD180

.btn-custom:hover, .btn-custom:focus, .btn-custom:active, .btn-custom.active, .open>.dropdown-toggle.btn-custom {
    color: #FFD180 !important;
    background-color: #837171;
    border-color: #837171; /*set the color you want here*/
}

编辑:颜色 (#333) 可能来自 bootstrap.min.css

中的这一行
.dropdown-toggle.btn-default{color:#333;background-color:#e6e6e6;border-color:#adadad}

关于html - 如何更改按钮悬停属性中的文本颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27446214/

相关文章:

javascript - 如何在 Javascript 中将列表项添加到无序列表

twitter-bootstrap - Bootstrap 按钮中的 Google Material Icons 对齐方式

php - 通过在 codeigniter 中加载 View 来打开 Bootstrap 模式对话框

python - 寻求更好的 Python 3.x+ 方法在一个函数中构建多个不同的 HTML

html - 为什么 Internet Explorer 不解析我的 CSS?

html - CSS:更改按钮布局

jquery - 有没有人见过会动态调整其大小的 jQuery 水平导航菜单?

html - 环绕图像的文本

html - 为什么我的元素上的 z-index 不起作用?

html - 是否有一种与浏览器无关的方法可以在不更改 HTML 标记的情况下增加复选框的大小?