悬停在按钮上的文字颜色会发生变化 [英] Text color change on hover over button

查看:128
本文介绍了悬停在按钮上的文字颜色会发生变化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



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



这是我目前的CSS:

 按钮,
input.button,
a.button,
input [type =submit] {
background:#2e77ae;
background:-moz-linear-gradient(top,#5590bd,#2e77ae);
background:-webkit-linear-gradient(top,#5590bd,#2e77ae);
背景:-o-linear-gradient(顶部,#5590bd,#2e77ae);
background:-ms-linear-gradient(top,#5590bd,#2e77ae);
背景:线性渐变(顶部,#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);
背景:线性渐变(顶部,#E6D332,#E6D332);
border-color:#2e77ae;}



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


解决方案

CSS属性 color 通常控制元素中的文本颜色。在你的情况下,要改变悬停时的颜色,使用:hover 说明符;

  input [type =submit]:hover {
color:#FF0000;
//你可以添加更多款式应用于悬停
}

请注意,您也可以使用 rgb(x,y,z)格式指定颜色。这里有一个小小的演示来说明:。您可以玩这个演示,并在这里查看源代码:另一个小链接



我希望有所帮助!

I am trying to change the color of the text inside the button on hover.

I can make the button itself change color, but I want the button text to change color too.

Here is my current 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;}

解决方案

The CSS property color controls the text color in elements generically. In your case, to change the color on hover, use the :hover specifier;

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

Note that you can as well specify the color using the rgb(x, y, z) format. Here's a little demo to illustrate: little link. You can play around with the demo and view the source here: another little link.

I hope that helped!

这篇关于悬停在按钮上的文字颜色会发生变化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆