如何更改此代码的背景色

时间:2019-01-16 20:43:23

标签: javascript html

我需要将此按钮的背景颜色更改为深红色。 当您将鼠标悬停在按钮上时,我还需要更改文本。我想说G.F.Y.T.S.当您将鼠标悬停在按钮上时。

下面的代码是我尝试过的:

<input type="button" onclick="location.href='http://google.com';" value="Roger George Expendables"/>

3 个答案:

答案 0 :(得分:0)

您需要在HTML代码中制作样式表或内联样式。从那里,您可以说出这样的话:

.button {
    background: #8b0000
}

接下来,您需要一个悬停选择器。这意味着您需要执行以下操作:

.button:hover {
    background: <hexvaluehere>
}

答案 1 :(得分:0)

为按钮添加CSS类,并为该类添加背景色和文本颜色。添加:hover以使课程结束。

答案 2 :(得分:0)

树道

  1. 添加样式的内联定义

http://google.com';“ value =” Roger George Expendables“ />

  1. 在HTML中添加样式部分并定义一个类

    。我的课{   背景颜色:黄色 }

    http://google.com';“ value =” Roger George Expendables“ />

  2. 在代码中添加对样式表的引用

相关问题