简体   繁体   中英

How do I change the background color on this code

I need to change the color on the background of this button to a dark red. I also need the text to change when you hover over the button. I want it to say GFYTS when you hover over the button.

The code below is what I've tried:

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

You need to make a stylesheet or inline styles in the HTML code. From there, you can say something like this:

.button {
    background: #8b0000
}

Next, you want a hover selector. This means you need to do something like this:

.button:hover {
    background: <hexvaluehere>
}

Add css class for the button and add background color and text-color un the class. Add :hover for the class over.

tree ways

  1. Adding inline definition of your style

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

  1. Adding a style section to your HTML and defining a class

    .myClass{ background-color:yellow }

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

  2. Adding a reference to a style sheet in your code

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM