I know this is probably an easy question to answer, but I've tried searching for this online but for the life of me couldn't figure out what to search for.
I have a dynamic button component that changes color based on its class name, but I can't figure out how to get the hover function to work when multiple classes are present.
My CSS:
.Button {
border-radius: 4px;
border: none;
padding: 10px 24px;
}
.G-green {
color: white;
background-color: #0F9D58;
}
.Button .G-green .button:hover{
cursor: pointer;
background-color: #0d8c4f;
}
.G-blue {
color: white;
background-color: #4285F4;
}
.G-red {
color: white;
background-color: #DB4437;
}
.G-yellow {
color: white;
background-color: #F4B400;
}
My button class:
import React from 'react'
import '../../StyleSheets/Button.css'
export default class Button extends React.Component{
constructor(props){
super(props);
this.state = {
}
}
render() {
return(
<div id="button">
<button className="Button G-green"
onClick={this.props.click}>{this.props.name}</button>
</div>
)
}
}
I tried just .G-green .button:hover
but this just overrides the main classes color to the hover color, otherwise I'm just getting a normal button with no hover functionality.
If anyone knows the answer to this, I would greatly appreciate it.
Also if you know what this type of styling is called, it would help me the next time I have to look something like this up again.