css - 悬停在按钮上时文本颜色发生变化

标签 css text colors hover

我正在尝试更改鼠标悬停时按钮内文本的颜色。

我可以让按钮本身改变颜色,但我希望按钮文本也改变颜色。

这是我当前的 CSS:

button,
input.button,
a.button,
input[type="submit"] {
background:#2e77ae;
background: -moz-linear-gradient(top, #5590bd, #2e77ae);
background: -webkit-linear-gradient(top, #5590bd, #2e77ae);
background: -o-linear-gradient(top, #5590bd, #2e77ae);
background: -ms-linear-gradient(top, #5590bd, #2e77ae);
background: linear-gradient(top, #5590bd, #2e77ae);
border-color:#2e77ae;}

button:hover,
input.button:hover,
a.button:hover,
input[type="submit"]:hover{

    background:#E6D332;
    background: -moz-linear-gradient(top, #E6D332, #E6D332);
    background: -webkit-linear-gradient(top, #E6D332, #E6D332);
    background: -ms-linear-gradient(top, #E6D332, #E6D332);
    background: linear-gradient(top, #E6D332, #E6D332);
    border-color:#2e77ae;}



button:focus,
input.button:focus,
a.button:focus,
input[type="submit"]:focus { 
    background-color:#E6D332;}

最佳答案

CSS 属性color 一般控制元素中的文本颜色。在您的情况下,要更改悬停时的颜色,请使用 :hover 说明符;

input[type = "submit"]:hover {
    color: #FF0000;
    //you can add more styles to be applied on hover
}

请注意,您也可以使用 rgb(x, y, z) 格式指定颜色。这里有一个小演示来说明:little link .您可以在此处试用演示并查看源代码:another little link .

希望对您有所帮助!

关于css - 悬停在按钮上时文本颜色发生变化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12139546/

相关文章:

ruby - 在 VIM 中更改 `rubyLocalVariableOrMethod` 颜色

ios - 通过 Storyboard命名颜色

javascript - 需要显示篮球的前三个字母,然后是点

android - 从 HTML 加载图像的 Webview 问题

javascript - Polyline Google Maps V3 中的标签

python - 在python中搜索有搜索词的文件

css - 是否有 CSS 父级选择器?

html - 我想在我的弹出窗口中添加关闭按钮

休眠前的 PHP 输出文本

r - 在 rgb() 中使用名为 r 的颜色,这样我就可以添加 alpha 值