conditional styling css code example
Example 1: conditional style react
class App extends Component {
constructor() {
super()
this.state = { isRed: true }
}
render() {
const isRed = this.state.isRed
return Example Text
}
}
Example 2: conditional styling css
Not in the traditional sense, but you can use classes for this, if you have access to the HTML. Consider this:
Text
Text
and in your CSS file:
p.normal {
background-position : 150px 8px;
}
p.active {
background-position : 4px 8px;
}
That's the CSS way to do it.