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:
这是我现在的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;}
4 个解决方案
#1
4
The CSS property color
controls the text color in elements generically. In your case, to change the color on hover, use the :hover
specifier;
CSS属性颜色一般控制元素中的文本颜色。在您的情况下,要更改悬停的颜色,请使用:hover指示符;
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.
注意,您还可以使用rgb(x, y, z)格式指定颜色。这里有一个小演示来说明:小链接。您可以在这里玩一下演示,并查看源代码:另一个小链接。
I hope that helped!
我希望帮助!
#2
2
If you want to change the color of the text, use the CSS color
property, like
如果您想更改文本的颜色,请使用CSS color属性,例如
input[type="submit"]:hover{
color :#E6D332;
}
#3
0
p.one{
color: DarkBlue}
p.one:hover{
color: yellow}
<html>
<head>
<title>Css Help</title>
<head>
<body>
<p class="one">Example TextExample TextExample TextExample TextExample TextExample TextExample TextExample TextExample TextExample TextExample TextExample TextExample TextExample TextExample TextExample TextExample TextExample Text<p>
</body>
<html>
Here is what I do:
我是这样做的:
a:hover{
color: #ffffff;
}
You can change the 'a' to whatever such as a paragraph 'p' or specify it the html file with a class
您可以将“a”更改为诸如段落“p”或将其指定为具有类的html文件
<p class="one">Example</p>
Them in CSS file do:
他们在CSS文件做:
p.one:hover{
color: #ffffff;
}
I hope I could Help.
我希望我能帮忙。
#4
-1
color:#(insert text color)
Put this in
颜色:#(插入文本颜色)
#1
4
The CSS property color
controls the text color in elements generically. In your case, to change the color on hover, use the :hover
specifier;
CSS属性颜色一般控制元素中的文本颜色。在您的情况下,要更改悬停的颜色,请使用:hover指示符;
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.
注意,您还可以使用rgb(x, y, z)格式指定颜色。这里有一个小演示来说明:小链接。您可以在这里玩一下演示,并查看源代码:另一个小链接。
I hope that helped!
我希望帮助!
#2
2
If you want to change the color of the text, use the CSS color
property, like
如果您想更改文本的颜色,请使用CSS color属性,例如
input[type="submit"]:hover{
color :#E6D332;
}
#3
0
p.one{
color: DarkBlue}
p.one:hover{
color: yellow}
<html>
<head>
<title>Css Help</title>
<head>
<body>
<p class="one">Example TextExample TextExample TextExample TextExample TextExample TextExample TextExample TextExample TextExample TextExample TextExample TextExample TextExample TextExample TextExample TextExample TextExample Text<p>
</body>
<html>
Here is what I do:
我是这样做的:
a:hover{
color: #ffffff;
}
You can change the 'a' to whatever such as a paragraph 'p' or specify it the html file with a class
您可以将“a”更改为诸如段落“p”或将其指定为具有类的html文件
<p class="one">Example</p>
Them in CSS file do:
他们在CSS文件做:
p.one:hover{
color: #ffffff;
}
I hope I could Help.
我希望我能帮忙。
#4
-1
color:#(insert text color)
Put this in
颜色:#(插入文本颜色)