8

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

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

这是我当前的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

5 回答 5

7

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。您可以在此处试用演示并查看源代码:另一个小链接

我希望这有帮助!

于 2012-08-27T09:47:54.960 回答
2

如果要更改文本的颜色,请使用 CSScolor属性,例如

input[type="submit"]:hover{
   color :#E6D332; 
}
于 2012-08-27T09:42:01.027 回答
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>

这是我所做的:

a:hover{
    color: #ffffff;
}

您可以将“a”更改为诸如段落“p”之类的任何内容,或者将其指定为带有类的 html 文件

<p class="one">Example</p>

它们在 CSS 文件中执行:

p.one:hover{
    color: #ffffff;
}

我希望我能提供帮助。

于 2015-03-23T23:42:40.387 回答
0
.btn:hover h3{
    color: #FFFFFF;
}

<button>您可以在after中为元素(例如文本)编写选择器,以在.btn:hover将鼠标悬停在按钮上时更新这些特定元素的 css 属性。

于 2021-04-13T19:51:58.237 回答
-1

color:#(insert text color)把这个放进去

于 2012-08-27T09:42:52.053 回答