正在加载视频...
视频加载失败
CSS container query for when an element is stuck with position: sticky 🔥 nav { container-type: scroll-state; } @container scroll-state(stuck: top) { .nav__content { --expand: 1; } } use custom property to morph CTA into a nav bar with transitioned grid-template-columns 😎
8 条评论

like seeing these and want to learn more about how to build awesome UIs for the web? Check out my newsletter, "The Craft of UI" (Thank you for all the support, each issue, each sub, etc. gets us one step closer to courses 🤙) 👉

could you share the codepen please <3

New article on substack! We are using css container queries for search experiences, where search input rendered in center of the page, and when you scroll more than the page height, it is fixed to the top (no js). Very powerful!

as in you wrote one? or you want to see one? 🧐 this demo in particular was an interesting revisit because there's gonna be like 3 or 4 ways to do this actually think turning this into a full size search input could be cool kinda reminds me of

Are you a team to come up with new ideas and css properties I never heard of before, or is it all you?

What is the browser support for :stuck?

Nitip

That is awesome, I always had to do this with JS. And I’m trying to use as much CSS as possible in favor of JS.
