Kaspars Foigts
[CSS] Pseudo and pseudon’t: adactio.com/journal/10000
I like CSS pseudo-classes. They come in handy for adding little enhancements to interfaces based on interaction.
Take the form-related pseudo-classes, for example: :valid, :invalid, :required, :in-range, and many more.
Let’s say I want to adjust the appearance of an element based on whether it has been filled in correctly. I might have an input element like this:
<input type="email" required>
Then I can write some CSS to put green border on it once it meets the minimum requirements for validity:
input:valid {
border: 1px solid green;
}
That works, but somewhat annoyingly, the appearance will change while the user is still typing in the field (as soon as the user types an @ symbol, the border goes green). That can be distracting, or downright annoying.
I only want to display the green border when the input is valid and the field is not focused. Luckily for me, those last two words (“not focused”) map nicely to some more pseudo-classes: not and focus:
input:not(:focus):valid {
border: 1px solid green;
}
If I want to get really fancy, I could display an icon next to form fields that have been filled in. But to do that, I’d need more than a pseudo-class; I’d need a pseudo-element, like :after
input:not(:focus):valid::after {
content: '✓';
}
…except that won’t work. It turns out that you can’t add generated content to replaced elements like form fields. I’d have to add a regular element into my markup, like this:
<input type="email" required>
<span></span>
So I could style it with:
input:not(:focus):valid + span::after {
content: '✓';
}
But that feels icky.
Update: See this clever flexbox technique by Hugo Giraudel for a potential solution.
[CSS] Pseudo and pseudon’t: adactio.com/journal/10000
input:not(:focus):valid — чтобы «светофор» валидации поля не отвлекал при наборе. Полезная идея Джереми Кита: adactio.com/journal/10000
Pseudo and pseudon’t adactio.com/journal/10000
RT smashingmag Oh, :not(:focus):valid can be used to “disable” validity styles while the user is typing. adactio.com/journal/10000 (via adac…
adactio.com/journal/10000 Pseudo and pseudon’t, a nice read for #css lovers, #css #frontend #web
Very clever! Using :not(:focus):valid to “disable” validity styles while the user is typing.adactio.com/journal/10000 @adactioJournal #CSS
Adactio: Journal—Pseudo and pseudon’t #css adactio.com/journal/10000
RT jimishparekh202 adactio.com/journal/10000 Pseudo and pseudon’t, a nice read for #css lovers, #css #frontend #web
RT soviac Very clever! Using :not(:focus):valid to “disable” validity styles while the user is typing.adactio.com/journal/10000 adactioJour…
RT nirmalkc Adactio: Journal—Pseudo and pseudon’t #css adactio.com/journal/10000
Validation Styles in #CSS adactio.com/journal/10000
RT Benjamin_Damm Validation Styles in #CSS adactio.com/journal/10000
Nice little CSS trick to “disable” validity styles while the user is typing.adactio.com/journal/10000 (via @openwebdaily)
Give me good selectors and I will rule the world… adactio.com/journal/10000 #css #rwd #webdev
RT acrevola Give me good selectors and I will rule the world… adactio.com/journal/10000 #css #rwd #webdev
RT Kseso Tip #css rápido y práctico: Pseudo and pseudon’t adactio.com/journal/10000 por adactioJournal
Pseudo and Pseudon’t - the magical CSS3 pseudo selectorsadactio.com/journal/10000#CSS3 #ModrenWeb
The :not(:focus):valid selector can be used to “disable” validity styles while the user is typing adactio.com/journal/10000
RT malimirkeccita Pseudo and pseudon’t adactio.com/journal/10000 via adactio #css #pseudo #selectors
Pseudo and pseudon’t adactio.com/journal/10000
https://adactio.com/journal/10000?skin=sci-fiNice read for CSS lovers :) #frontEnd #webDevelopment #tech
Заметка Джереми Кита про более удобное использование псевдокласса :valid (adactio.com/journal/10000) уже в переводе — css-live.ru/articles/psevd…
Top story: Adactio: Journal—Pseudo and pseudon’t adactio.com/journal/10000, see more tweetedtimes.com/helikopterdsgn…
Oh yea good call! input:not(:focus):valid - show validation styles when the value’s accepted but no longer focused adactio.com/journal/10000
:not(:focus):valid can be used to “disable” validity styles while the user is typing adactio.com/journal/10000
Pseudo and pseudon’t adactio.com/journal/10000
Pseudo and pseudon’t adactio.com/journal/10000
#css Pseudo and pseudon’t -> adactio.com/journal/10000
RT carlosmoran092 #css Pseudo and pseudon’t -> adactio.com/journal/10000
CSS的valid伪类的妙用。adactio.com/journal/10000
Adactio: Journal—Pseudo and pseudon’t adactio.com/journal/10000
Pseudo and pseudon’t adactio.com/journal/10000 #css
RT gatoalberto Pseudo and pseudon’t adactio.com/journal/10000 #css
Good thoughts about pseudo classes: adactio.com/journal/10000
Adactio: Journal—Pseudo and pseudon’t adactio.com/journal/10000
Pseudo and pseudon’t - a great article adactio.com/journal/10000
Pseudo and pseudon’t adactio.com/journal/10000
I like CSS pseudo classes, but they do get messy. Article: Pseudo and pseudon’t - adactio.com/journal/10000 #CSS #pseudo #webdesign
RT DamienBAus I like CSS pseudo classes, but they do get messy. Article: Pseudo and pseudon’t - adactio.com/journal/10000 #CSS #pseudo #webd…
A some-what icky but neat trick to styling valid inputs in a less obtrusive manner adactio.com/journal/10000
Pseudo and pseudon’t adactio.com/journal/10000 #css #input cc @totya24 @vinogabi
RT fpshu Pseudo and pseudon’t adactio.com/journal/10000 #css #input cc totya24 vinogabi
[b0t] Pseudo and pseudon’t: this CSS trick by Jeremy Keith makes filled inputs simple and awesome adactio.com/journal/10000 #web_design
/v @adactio // Pseudo and pseudon’t adactio.com/journal/10000
Pseudo and pseudon’t adactio.com/journal/10000