My question is similar to this: Select label only if input is empty and not focused?
But it’s a bit more tricky because I need to select a pseudo-element of the input field if:
- input field is not focused
- something is in value
I have no access to the html. I came up with this but no matter what combination I try it’s not selecting how I want it.
<input type="text" id="filter" value="lp">
.container input#filter:not([value=""]):not(input:focus)::before {
content:'';
}
2
Answers
The
<input>
element is a replaced element and as per the note on MDN:This means that no matter what you do, the
::before
pseudo-element will never show, even something as benign as:Will have no visual effect.
Use this instead
and don’t forget to add placeholder to all the inputs you can do this with js