Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

css input required not focused or disabled

Tags:

css

I'm trying to create a css rule to change the background color of an input if it is required, but bot disabled or in focus

I have this, but it's not working obviously!

<input type="tel" class="form-control" placeholder="Phone" name="phone" value="" required>

and css:

input:not(disabled):not(focus):required {
    background-color: rgba(255,0,0,.10)
}
like image 436
Sandra Willford Avatar asked Jul 27 '26 02:07

Sandra Willford


1 Answers

Use the : for your pseudo-selectors :disabled and :focus

input:required:not(:disabled):not(:focus)
like image 194
Roko C. Buljan Avatar answered Jul 28 '26 20:07

Roko C. Buljan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!