0

I have a button in my React project that I've set up this way.

<label style={styles.label}>
    <input style={styles.input} type="file" accept="image/*" onChange={this.onUpload} />
</label>

The styles are set up like this


label : {
    borderRadius: '1vh',
    cursor: 'pointer',
    height: '2.5vh',
    margin: '0.5vh',
    minWidth: '50px',
    fontSize: '1.7vh',
    justifyContent: 'center',
    alignItems: 'center',
    display: 'flex',
    flexDirection: 'row',
    backgroundColor : 'green',
    color           : 'black',
    opacity         : '0.9',
    '&:hover': {
        backgroundColor : 'green',
        color           : 'black',
        opacity         : '1',
    },
},
input : {
    zIndex   : -1,
    position : 'absolute',
    opacity  : 0,
    visibility : 'hidden',
}

The hover style is not activated while the mouse hovers over the label and I'm not sure what I'm doing wrong here.

Zephyr
  • 1,612
  • 2
  • 13
  • 37

1 Answers1

1

You can't add hover with inline css (How can I write 'a:hover' in inline CSS?). Use external css for this. It is mentioned in the React documentation how to add external stylesheet

Oktay Yuzcan
  • 2,097
  • 1
  • 6
  • 15