kizu
kizu.dev · Personal blog · on HN since 2023
kizu, a front-end developer, writes about advanced CSS techniques such as anchor positioning, scroll-driven styles, and fitting text to width.
What HN saysHN commenters cite his fit-to-width and CSS workaround posts as proof that tricks once thought impossible work in CSS without JavaScript.
16HN people shared it
6linked it in comments
12stories submitted
15story points
5 months agolast shared
2023people per year2026
Most-shared posts
- 1Fit-to-Width Text3 people · 5 points · first shared 2023 · discussion on HN
- 2Future CSS: Anchor Positioning3 people · 2 points · first shared 2023 · discussion on HN
- 3Position-Driven Styles2 people · 1 points · first shared 2023 · discussion on HN
- 4Fit to width2 people · first shared 2024
- 5Layered Toggles: Optional CSS Mixins1 people · 2 points · first shared 2024 · discussion on HN
- 6Solving Shrinkwrap: New Experimental Technique1 people · 2 points · first shared 2026 · discussion on HN
- 7Counters and Stones1 people · 1 points · first shared 2023 · discussion on HN
- 8Scroll-Driven State Transfer1 people · 1 points · first shared 2023 · discussion on HN
- 9Cyclic Dependency Space Toggles1 people · 1 points · first shared 2023 · discussion on HN
- 10Self modifying variables1 people · first shared 2025
- 11Svg linked parameters workaround1 people · first shared 2026
What HN people wrote when they linked it
eyelidlessness · 2023-06-29
Weirdly enough, with the new scroll-driven animations spec (the spec’s terminology), you can do all sorts of position-based styling without any actual scrolling taking place[1]. Of course you can also use it for its intended purpose of actually detecting scroll position.
But this also unlocks a lot of other style query problems, like the cursed wrap detection. For some cases, container queries should also be sufficient. And contrary to many of the other responses here, yes I think this flexibility is important progress. There are tons of fairly straightforward (even trivially specified) layout techniques that are currently next to impossible without some combination of hardcoding measurements and/or JS, which are going to become reasonably achievable in the next year or two. That’s fantastic. And for everyone who complains about this complexity at the styling level, it’ll eventually eliminate the need for a whole class of runtime JS doing a whole bunch of inefficient calculations badly.
1: https://kizu.dev/position-driven-styles/
spiralganglion · 2026-05-29
Credit to Roman Komarov who came up with the approach [1], and Todd Matthews [2] who made the art assets.
1: https://kizu.dev/svg-linked-parameters-workaround/
2: https://www.seaofclouds.com
kizmarh · 2025-11-26
Not by themselves, at least today, as we can't currently modify the value of a custom property by using itself in the calculation. But in the future we will have an `inherit()` functional notation that will unlock this (and at least Chrome implemented it in Canary already — https://blog.kizu.dev/play-with-inherit-function/).
It is possible to use style queries and some hacks (https://kizu.dev/self-modifying-variables/) to achieve this today, but that doesn't bring this closer to production, as Firefox still does not support them (but will be soon).
swyx · 2024-11-16
i asked this on bluesky (https://bsky.app/profile/swyx.io/post/3lb2x53wuwc2y) and immiediately got this https://kizu.dev/fit-to-width/ which means theres no technical barrier now, we just need the powers that be to prioritize it
anyone with influence on the CSSWG?
staminade · 2024-05-10
The article I linked goes into the details, but basically a relative approach constrains your markup: The positioned thing must be a child of the relatively positioned anchor or a wrapper element, and you often cannot sensibly position it without using JS to check the location of the anchor. E.g. a popover menu for a button must check if the button is close to an edge of the viewport and position the menu element appropriately. Anchor positioning will do this automatically.
Also, if support for multiple anchors is included, then it opens up some very interesting capabilities to do things like draw arbitrary diagram connectors between elements: https://kizu.dev/anchor-positioning-experiments/
niutech · 2024-11-20
There is pure CSS solution: https://kizu.dev/fit-to-width/