Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS Hover Text Changing Color With Button

Tags:

html

css

So, it's pretty easy to set a hover over effect for an element. But what I want is when the user hovers over a button that has text in it, to make the button turn from black to white and the text from white black at the same time. Instead of two separate elements. How should I do this?

Thanks!

#signUpBox {
    width: 150px;
    height: 47px;
    border-style: solid;
    border-width: 1px;
    margin: auto;
    margin-top: 25px;
    border-radius: 2px;
}

#signUpBox:hover {
    background-color: #ffffff;
}

h3 {
    text-align: center;
    margin-top: -35px;
    letter-spacing: 1px;
    font-size: 17px;
}
like image 914
user2605157 Avatar asked Dec 16 '22 02:12

user2605157


2 Answers

I'm not sure how you have the code set up but this would work on a div with an onclick function attached as a button:

#signUpBox {
    width: 150px;
    height: 47px;
    border: solid 1px #000;
    margin: auto;
    margin-top: 25px;
    border-radius: 2px;
    color:#000;
    background:#fff;

}

#signUpBox:hover {
    background: #000;
    color:#fff;
}

HTML:

<div id="signUpBox">This is a test</div>

DEMO

like image 159
Phlume Avatar answered Jan 01 '23 19:01

Phlume


#signUpBox:hover {
    background-color: #ffffff;
    color:#000000;
}
like image 27
Joe Avatar answered Jan 01 '23 20:01

Joe