Future CSS Tip! ⚡️ You can combine CSS :has() & :user-valid/:user-invalid to power micro…
@jh3yy15万 位关注者
284,043 次观看
10 条评论
评论来自 X (Twitter) 上的原帖

@jh3yy
Here's that @CodePen link! 🚀 Wildly. This one has "varied" support atm. It works in Safari Technology Preview ✅ In Chrome 118 it works to activate but then doesn't deactivate 🤔 In Firefox, the :has() flag in Nightly doesn't work for me atm 🥲
20 个赞

@jh3yy
You could already do this if you have access to :has() 👀 But it requires somewhat of a transparent placeholder hack 🤓 .group:not(:focus-within):has(:invalid:not(:placeholder-shown)) { ... } Here's the @CodePen for that way 👇
11 个赞

@DerSchickMann
Man! 😲
1 个赞

@jh3yy
You can do a version with :has() alone. But it isn't as clean as using :user-valid/:user-invalid IMO 🤓
1 个赞

@MuwaffaqBadawi
Pretty hot 🔥🔥🥵
1 个赞

@jh3yy
We're trying! 😍
1 个赞

@HeliosCreator
I wonder if you can combine this with :after { content: “invalid email”; } somewhere above the input.
1 个赞

@jh3yy
You could! 💯 An explicit element could be an easier solution to maintain. The idea here is also that I'm leaning into the built-in validation of the browser. So you would get the little browser built-in tooltips 🤓
4 个赞

@Adebobby_tech
@pikaso_me screenshot this
1 个赞

@pikaso_me
@jh3yy Here's your screenshot. ⚡ Want to automatically post your tweets on Instagram? Visit