jhey โ–ฒ๐Ÿป๐ŸŽˆ Profile picture
โšก๏ธ Showing you how to bring ideas to life with code ๐Ÿ’ผ Senior DX at @vercel ๐Ÿซก Ex-@google ๐Ÿป https://t.co/rRqcWhrAgW ๐Ÿ“บ https://t.co/7FlZg84Rr8 โค @seaotta
Scale V Profile picture 1 subscribed
Sep 13, 2023 โ€ข 5 tweets โ€ข 3 min read
Future CSS Tip! ๐Ÿ

You could create those Apple-style dynamic CTA reveals with container style queries and scroll-driven animations with zero JavaScript ๐Ÿ‘€ (Sticking to the #AppleEvent theme)

.cta {
animation: activate both, activate reverse;
animation-timeline: --section, view();
animation-range: entry, cover 50%;
}

keyframes activate {
0% { --active: 0; }
100% { --active: 1; }
}

@ container style(--active: 1) {
.cta__bloom {
scale: 0.99;
transition: scale 0.5s var(--back); /* ๐Ÿ‘ˆ linear() */
}
.cta a {
scale: 1;
grid-template-columns: var(--content-size, auto) 36px;
transition: scale 0.2s 0s, grid-template-columns 0.5s 0.6s var(--elastic);
}
}

There's a fair bit of code here ๐Ÿคฏ

But, the idea is this...

1. Use a scroll-driven animation scoped to each section for each CTA to change a custom property value (--activate) between 1 and 0.
2. Use a container style query to dictate the transition sequence for each moving part making use of transition-delay.
3. Make use of linear() easing to get the right effect โšก๏ธ

It's wild to put all these APIs together and see what's possible. There are likely some spots to tidy this up ๐Ÿ’ฏ These are powerful combinations for sure though! ๐Ÿ’ช

@CodePen link below! ๐Ÿ‘‡
Here's that @CodePen link! ๐Ÿš€

You'll need to be in Chrome 115+ to see everything working as it should ๐Ÿคž

We're combining:
โ€“ Scroll-driven animation
โ€“ linear() easing
โ€“ Container style queries

codepen.io/jh3y/pen/zYyzYโ€ฆ
Aug 23, 2023 โ€ข 4 tweets โ€ข 2 min read
CSS Tip! โœจ

You can create icon sprite animations using the steps() animation-timing function ๐Ÿค™

You could use this to create little icon button animations, etc. ๐Ÿ˜Ž

But how do you do it? Like this ๐Ÿ‘‡

button img {
object-fit: cover;
object-position: 0 0;
}

The image is a sprite strip of the frames in the animation. To animate the frames, you do something like this:

[aria-pressed=true] img {
animation: play 0.5s steps(20) forwards;
}

@ keyframes play {
to {
object-position: 100% 0;
}
}

We are toggling aria-pressed in our scripts to show a pressed state and we can then fire the animation to play our sprite ๐ŸŽ‰

Check out the video that breaks things down a little bit

@CodePen link blow! ๐Ÿ‘‡

Here's that @CodePen link! ๐Ÿš€

This was a bunch of fun to make. In fact, the hardest part was making the sprite ๐Ÿ˜‚

codepen.io/jh3y/pen/KKbpeโ€ฆ
Feb 28, 2023 โ€ข 4 tweets โ€ข 3 min read
Have you tried out the View Transitions API? โœจ

Been playing have a play with it this evening ๐Ÿ‘€

A bit of JavaScript Web Animations API usage for those rainbow lines but sets me up for another demo idea! ๐Ÿ’ก

Repo && deets ๐Ÿ‘‡ The View Transitions API is gonna be a game-changer for the flexible ways in which you can use it with UI ๐Ÿ’ฏ

For a guide to the API, @jaffathecake has you covered ๐Ÿ‘‡

developer.chrome.com/docs/web-platfโ€ฆ
Nov 11, 2022 โ€ข 5 tweets โ€ข 3 min read
CSS Tip! ๐Ÿš€

Use custom properties to power parallax effects ๐Ÿ˜Ž

Use JavaScript to pass the pointer position to CSS. Let CSS handle the rest, moving things at different rates ๐Ÿ’ช

card:hover{
rotate: calc(var(--ratio-y) * 50deg);
}

Play with card effects โœจ

Demo link below! ๐Ÿ‘‡ Here's that @CodePen link! โšก๏ธ

It's kinda hard to explain everything going on here in one tweet ๐Ÿ˜…

The magic part is how you can use JS to work out something for you and then let CSS do the rest, you're decoupling them in a way.

Let's go over it ๐Ÿ‘‡

codepen.io/jh3y/pen/wvXvEโ€ฆ
Oct 6, 2022 โ€ข 4 tweets โ€ข 3 min read
CSS Tip! โœจ

You could use :has() combined with sibling combinators and other things to build a working 3D CSS Connect 4 ๐Ÿค“

.col:has([row=p-1]:checked) +
...
.col:has([row=p-1]:checked) ~ .result {
--win: 1; --winner: var(--p);
}

Demo link below! ๐Ÿ‘‡ Here's that @CodePen link! ๐Ÿš€

The performance of CSS :has() is pretty incredible. There's another demo I'll share where it does some pretty "extra" stuff and it handles it like a champ ๐Ÿ’ช

codepen.io/jh3y/pen/Jjvapโ€ฆ
Oct 5, 2022 โ€ข 5 tweets โ€ข 3 min read
Wild to think how close we are to almost being able to build this with CSS alone ๐Ÿคฏ

This is a version I built with JavaScript using GSAP โœจ

It does have perks like infinite smooth scroll ๐Ÿ‘€

But, think I'll try building a CSS version without ๐Ÿค“

Demo link for this one below! ๐Ÿ‘‡ Here's that @CodePen link! ๐Ÿš€

You can spin that mouse wheel to your heart's content on this and it'll keep going ๐Ÿ˜…

codepen.io/jh3y/pen/WNRvqโ€ฆ
Sep 13, 2022 โ€ข 6 tweets โ€ข 2 min read
Future CSS Tip! ๐Ÿ”ฎ

Use animation-timeline to create scroll-linked animations ๐Ÿคฏ

li { view-timeline-name:in; }
img { animation-name:reveal; animation-timeline:in; }

Animation is bound to the li position in the viewport โœจ

Check these image reveals ๐Ÿ˜Ž

Demo link/info below! ๐Ÿ‘‡ Here's that @CodePen link! ๐Ÿš€

And this should work in your browser today ๐Ÿ™Œ That's because it's using a polyfill that's currently under development as scroll linked animations are experimented with ๐Ÿ˜Ž

codepen.io/jh3y/pen/RwyGBโ€ฆ
Sep 10, 2022 โ€ข 4 tweets โ€ข 2 min read
This one was born out of the number of skeleton loaders I saw whilst in the US ๐Ÿ˜… (My cell reception was "weak")

Amazed how many of them were quite jarring though ๐Ÿ‘€

Using this one as a stepping stone to get back on the video editing wagon. Also made captions for this one ๐Ÿ™Œ Sometimes you get in a rut and you just need to "Make a thing!" to get yourself going again.

It's been like that with these. I'm still trying to find that "Sweet process". But, the more of them I make, the better I get at it. And that's the same with anything.
Aug 26, 2022 โ€ข 4 tweets โ€ข 2 min read
Future CSS Tip ๐Ÿ”ฎ

The Anchoring API lets you anchor an element to another without JS โš“๏ธ

Don't need to be siblings/nested + you can define positions when things get clipped ๐Ÿคฏ

.anchor{anchor-name:--a;}
.boat{position-fallback:--backup;}

Check this video and demo link below! ๐Ÿ‘‡ Here's that @CodePen link! ๐Ÿš€

You'll need @chromecanary with the "Experimental Web Platform Features" flag set โ›ณ๏ธ

This is super early stages โš ๏ธ

But if you play, try resizing the container and see how the boat moves when it gets clipped ๐Ÿ”ฅ

codepen.io/jh3y/pen/WNzBXโ€ฆ
Aug 26, 2022 โ€ข 5 tweets โ€ข 3 min read
To think, this UI pattern will be possible without any JavaScript using the Pop-Up API and CSS Anchoring ๐Ÿคฏ

<button popuptoggletarget="products">Products</button>
<div popup id="products">
<a autofocus>HTML</a>
</div>

"autofocus" enables keyboard nav ๐Ÿ”ฅ

Demo link below ๐Ÿ˜Ž Here's the @CodePen link! ๐Ÿš€

This is currently only in @chromecanary behind the "Experimental Web Platform Features" flag โ›ณ๏ธ

I'm also "mocking" the anchoring here with a smidge of JavaScript ๐Ÿค

Actual CSS-only anchoring is on the way though! ๐Ÿ‘‡

codepen.io/jh3y/pen/YzabBโ€ฆ
Aug 24, 2022 โ€ข 10 tweets โ€ข 5 min read
CSS Tip! ๐Ÿš€

You can select the previous siblings of an element with :has() to create cool hover effects like this OS dock๐Ÿ”ฅ No JS ๐Ÿ˜Ž

:root{--lerp-1:0.525;}
a:has(+a:hover){
--lerp:var(--lerp-1);
translate: 0 calc(var(--lerp) * -75%);
}

Demo link and explanation below! ๐Ÿ‘‡ First, here's that @CodePen link! ๐Ÿš€

You'll need to be in Safari, Chrome BETA, or you can use Chrome/Firefox with flags enabled โ›ณ๏ธ

Try not only :hovering the items, but also tabbing through them too โœจ

codepen.io/jh3y/pen/mdxggโ€ฆ
Aug 23, 2022 โ€ข 5 tweets โ€ข 3 min read
CSS Tip! ๐Ÿ“ข

You could use CSS :has() to make a CSS-only dark mode toggle with a checkbox ๐Ÿง

:root:has(:checked) {--dark:1;}

If you can, use a button and [aria-pressed] ๐Ÿ™
(Toggle via JS โœจ)

:root:has([aria-pressed=true]) {--dark:1;}

It powers this demo ๐Ÿ˜Ž Link below! ๐Ÿ‘‡ Here's that @CodePen link! ๐Ÿš€

codepen.io/jh3y/pen/poLBvโ€ฆ
Aug 6, 2022 โ€ข 5 tweets โ€ข 2 min read
Lil CSS Tip ๐Ÿค

Forgot to post the vertical version of this curved scroller ๐Ÿ’ˆ

Want that overscroll bounce? Add a padding element and remove the scroll snap alignment โšก๏ธ

.track:last-child { scroll-snap-align: none; }

s/o @argyleink for this "trick" ๐Ÿค™

Demo link below! ๐Ÿ‘‡ Here's that @CodePen link! ๐Ÿš€

codepen.io/jh3y/pen/KKoRXโ€ฆ
Aug 6, 2022 โ€ข 5 tweets โ€ข 3 min read
Wanna play a game? ๐Ÿš€

How quickly can you wake up Stan? Beat my score? ๐Ÿฆ–

This game is built with CSS using :has() && Houdini

No JavaScript necessary! ๐Ÿคฏ

Amazing what you can do with CSS alone โœจ

Demo link and articles below ๐Ÿ‘‡ Here's the @CodePen link! ๐Ÿš€

You'll need a browser that supports :has() && Houdini for the best experience ๐Ÿ™

๐Ÿ‘‰ codepen.io/jh3y/details/Wโ€ฆ via @CodePen
Aug 5, 2022 โ€ข 4 tweets โ€ข 2 min read
Future CSS Tip! ๐Ÿ”ฎ

You can use CSS :has() to select a previous sibling based on a condition โšก๏ธ

This animated form requires no JavaScript ๐Ÿ˜Ž

If a group is focused, hide the previous one! ๐Ÿ‘€

.group:has( ~ .group:focus-within) {
--show: 0;
--offset: -1;
}

Demo link below ๐Ÿ‘‡ Here's that @CodePen link! ๐Ÿš€

codepen.io/jh3y/pen/abYBKโ€ฆ
Jul 18, 2022 โ€ข 6 tweets โ€ข 3 min read
Future CSS Tip! ๐Ÿ”ฎ

Use :has() to power <form> micro-interactions and theme ๐Ÿ˜Ž No JavaScript. Animations powered by <input> state ๐Ÿš€

.group:has(:invalid) {
animation: shake 0.5s;
}

form:has(.email:valid):has(.password:valid) .submit {
--color: green;
}

Demo link below ๐Ÿ‘‡ Here's that @CodePen link! โœจ

๐Ÿ”Ž :has is landing in Chrome 105 and is already in Safari as of version 15.4 ๐Ÿ™Œ

Have you tried CSS :has() yet? What could you use it for?

๐Ÿ‘‰ codepen.io/jh3y/pen/yLKMOโ€ฆ via @CodePen
Jul 18, 2022 โ€ข 7 tweets โ€ข 4 min read
More than 74 billion people use CSS daily

But, so many don't know how to center a <div>

Here are 4 ways to do it so you can show off to your friends in <style> ๐Ÿ‘‡๐Ÿงต Let's assume we have a container element and a child element. We want to center both horizontally and vertically.

We could use "display: grid" and "place-content: center"

That's a good start! โœจ

๐Ÿ‘‰ codepen.io/jh3y/pen/MWVJPโ€ฆ via @CodePen /*   Given:     <div class="container">       <div
Jun 1, 2022 โ€ข 7 tweets โ€ข 3 min read
Oh, this? ๐Ÿ‘€

Jus' a pure CSS image zoom using CSS primitives ๐Ÿ”ฅ

โ€“ :has()
โ€“ object-view-box
โ€“ Houdini @ property

Code ๐Ÿ‘‡

img {
object-view-box: inset(var(--top) ...);
}

:root:has(#car:checked) {
--top: 61%;
...
}

Amazing ๐Ÿฅฒ

๐Ÿ‘‰ codepen.io/jh3y/pen/QWQrVโ€ฆ via @CodePen Let's break down what's going on here ๐Ÿ˜Ž

I will not call this a thread...

The first property "object-view-box" allows us to apply an SVG like viewBox to an element such as an <img>. In this demo, I map the different "viewBox" to the different "Zoom" spots. img {   object-view-box: inset(     				var(--inset-top)
May 31, 2022 โ€ข 4 tweets โ€ข 2 min read
Pure CSS && SVG Tic Tac Toe! โšก๏ธ

You can build this without any JavaScript at all ๐Ÿซต๐Ÿ˜Ž

Went for a CyberPunk theme here, how would you style it? ๐ŸŽจ

Wanna learn how to make it? Course link is below! ๐Ÿ‘‡

๐Ÿ‘‰ codepen.io/jh3y/pen/KKNwpโ€ฆ via @CodePen Learning with the "Impractically practical" โœจ

You'll pick up a bunch of CSS techniques you can use elsewhere ๐Ÿ’ช

Check out the "FREE" @eggheadio course โญ๏ธ

โ€“ Layout techniques
โ€“ Animating SVG
โ€“ "that" frosted effect
โ€“ And more!

egghead.io/courses/tic-taโ€ฆ
Jan 14, 2021 โ€ข 6 tweets โ€ข 4 min read
Did you see @CodePen's "Most Hearted of 2020"? ๐Ÿ’•

Many awesome things on there! ๐Ÿ’ฏ

Honored to have not one, but four of my pens featured ๐ŸŽ‰ To see one of my whimsical creations in the top 5 is amazing ๐Ÿคฏ

Pens down below ๐Ÿ‘

๐Ÿ‘‰ codepen.io/2020/popular/pโ€ฆ Big shout out to @CodePen ๐Ÿ™ It's a wonderful platform for sharing creative things and it's opened up a bunch of doors for me already.
Oct 11, 2020 โ€ข 18 tweets โ€ข 7 min read
How to make single div(any element) CSS art - A mini thread ๐Ÿงต

Spoiler: No magic ๐Ÿช„ All that's required is patience and knowing your way around some properties ๐Ÿ‘

Let's gooo! ๐Ÿ‘‡

Starting with this timelapse โณ The "Big" trick? Layered background images ๐Ÿ˜ฎ

With CSS you can give many backgrounds to an element. Comma separate background images and you're golden โœจ๐Ÿ†

What would this give for a 60px square? ๐Ÿค”

๐Ÿ‘‰ codepen.io/jh3y/pen/eYzNGโ€ฆ