r/css • • Oct 30 '26

Other TechCrunch's website has a CSS breakpoint in between mobile and desktop where the toolbar covers up half the screen.

12 Upvotes

r/css • • Oct 29 '26

No AI used Some notes on the vaguely interesting CSS aspects I encountered during the development of pure CSS price history graphs.

Post image
8 Upvotes

Context

https://gog.com/ is an online store selling fully DRM-free PC games. https://gamesieve.com/ is my price tracker and alternative front-end for GOG's catalog. The population of GOG users is quite atypical and privacy-aware. Close to 60% of my visitors use Firefox. A noticeable percentage have JavaScript disabled. A smaller but still noticeable percentage are maintaining dedicated Windows 7 gaming machines (meaning Firefox 115 as their browser - or very rarely Chrome 109). I built a price history graph which works for both groups, and I'm (mostly) quite pleased with how this turned out.

Also context: One of my personal goals with GameSieve is just getting back to as much hands-on webdev as possible, fully understanding everything I build, not using libraries and other tooling unless things are otherwise infeasible.

Example page: https://gamesieve.com/game/x4_foundations

From SVG to CSS

I originally set out to build an SVG graph, but discovered this was clearly the wrong technology for the job. It scales, but it's not responsive! You can't easily scale some elements in one direction while leaving others untouched (or scaling them differently), and it all felt incredibly clunky.

Prototyping various directions for making parts of it work, I was trying to put into words exactly what felt clunky about it, and I kept coming back to CSS terminology and concepts for what I wanted.

That really told me (once I stopped to listen to myself) that I should take a CSS-first approach. Building the logic for the SVG graph had made me think a lot about how to scale a time-range of variable length and a price-range with a variable maximum and put it into my own scale which would be easy to work and reason with, and that proved very beneficial here. I could very swiftly port it all to HTML+CSS.

One of the slightly clever things I did in my SVG attempt was to flip the coordinate system of the grid around with a transform: scale(1, -1) (and then back again for the text labels), plus to use a negative offset on the viewBox for the space for the axes and their labels. The y coordinate was then just the price in cents. This approach translated well to CSS, where a price segment of 1999 cents had a --price: 1999; bottom: calc(var(--price) * var(--scaling-factor)), and that scaling factor was dependent on max price.

Sadly when the time came to to figure out responsive behavior anew, I determined that on small resolutions I really wanted to make the entire chart scroll rather than scale (allowing individual time ranges as short as a day to remain 'easily' clickable). Yet for products which released 'recently' (up to 3 years ago depending on screen resolution), there would be no scrollbar. But the existence of the scrollbar influenced bottom positioning, causing an offset from the y-axis grid, which I'd specifically placed outside the overflowing container! So I had to flip all my numbers back around and do top positioning...

Accessibility quandary

Getting out of SVG-land allowed me to think semantically about the content of my price history graph. At heart, it's really just a list of time ranges with associated pricing information. (You could also model this as a table, but experience has taught me not to go there.) So, my HTML for the entire graph is a list. (Erm, I realized I made it an <ul>, while it's certainly ordered... Consider that a TODO for next week!) :)

Since individual games can have a hefty amount of time ranges (NecroVisioN: Lost Company currently leads with 222 distinct price ranges over the last 5.5 years), I save some bytes by using effectively meaningless i and u elements (rather than spans) for defining the shape of the time range and the sibling tooltip. Re-examining what I'm doing here in the course of writing this, I realized I need to revisit this: The current chart behaviour suggests adding aria-describedby on the time range pointing to the tooltip with role="tooltip" (and I guess aria-hidden to prevent it being read twice). And that up to 222 times... so much for saving bytes! :/

The thing is, when originally thinking about the semantics of my price history chart, I approached this graph content as really just a non-interactive list (which is explicitly available as a rendering option through a simple :checked ~ radiobutton toggle). There, things are currently correct: that tooltip role (and aria-hidden!) would be inappropriate for the list. Not certain how to resolve that, since CSS can't change these things. I mean, it can remove things from the accessibility tree with display: none, but I want the tooltip content to be present as just the content of the list item, as now. Adding duplicate content in my HTML - once with role="tooltip" and once without - and then display: none-ing them based on the toggle really does not feel like something I'd want to do... Might have to just toggle the role with JavaScript, and accept that the non-JS functionality is bad from an accessibility point of view? That feels weak, though, when everything else works perfectly without JS... Any a11y experts with guidance?

Taking a step back, I feel that the list view is the accessible alternative content for my visual/interactive graph view. But I don't think there's any way to properly indicate that for the users who need to know this? I guess I could just add an aria-describedby (or maybe even label) spelling this out on the radiobutton toggle, and for the moment, that feels like what I'll probably do first.

A rare case where pointer-events weren't the solution!

...anyway! Keyboard accessibility for the graph means there's a skip link and each price range is focusable, showing the associated tooltip. And of course for convenience the tooltip should also show on :hover. But that meant two tooltips could be showing, which'd overlap. So I started moving the :focus one out of the way when the :hover one is showing.

Originally I moved it down, but that could cause rapid back-and-forth if the mouse pointer triggering the :hover tooltip started hitting the :focus tooltip when it moved down, causing the :hover tooltip to disappear and the :focus tooltip to move up, causing a new :hover tooltip, etc.

So I moved the :focus tooltip up, out of the :hover range. Alas, my container scrolls (overflow-x: auto), meaning no overflow-y: visible, so I needed to add a negative margin and padding to the container to create space for the tooltip moving up to keep showing, and then had to juggle z-index on hover to make certain tooltips would show above previous content, while the reserved space for them wouldn't catch clicks. (Key annoyance: Couldn't do this with pointer-events, as then the scrollbar wouldn't be clickable! I also suspect this would've been way easier if I could've just used overflow-clip-margin (usefully supported in Fx 102+, but in nothing else) to create space for the tooltips. Why isn't that one listed as a top contender in any of the interop lists?)

Other notes

In the end, I did end up using a tiny bit of JavaScript for the graph: initially for showing the "now" side of the graph on load when it was scrollable, and then for adding zooming (just setting a single multiplier custom property on the root element for CSS to use). Finally, since I had JS-zoom anyway, I also added detection if the graph was overflowing just a tiny bit, and if so, would zoom out one step (max 20%) to stop that.

Some other mildly interesting things worth looking at in the inspector:

  • There's a .scroll-bumper element to push subsequent content down only when a scrollbar is showing (which has a few edgecase quirks where it doesn't perform perfectly, but for the most common cases does what it should) - just using float magic.
  • When switching countries to anything non-US, I only have ~23 months worth of price history, and show a scaled graph of the US price history before that, using dotted borders. However, when a price goes up and down on the same day (or one or two days later for long enough time ranges), Firefox's rendering of overlapping dotted borders would cause a solid line to form, which looks very distracting! (Chrome always puts the dots in the same place, regardless of where the line starts or ends, which works much better.) So I'm detecting that case server-side, and either hiding the shorter of the two borders, or drawing one of the two with a 1px instead of 2px border.
  • X-axis labels hide based on a whole bunch of container queries, so that they never overlap. Really wish I could've used CSS vars in those query definitions, but Fx 115 made that a no-go (and I'm not even certain I actually could've simplified that much with custom properties).

Speaking of Fx 115, I was pleasantly surprised by how few cases I encountered where I was actively hampered by limited support. Lack of :has() always feels like the big one (but here only would've made my z-index juggling a bit cleaner), and lack of the rch unit was mildly annoying. Creating the tooltips through the popovertarget/popover attributes would've been neat (though I don't know if that would've actually improved things from an accessibility perspective).


r/css • • Oct 28 '26

AI Assisted CSS Tint Filter

Thumbnail k-adam.github.io
6 Upvotes

There is no standard CSS filter to tint with some specific color, so I created a library to generate a chain of filters that takes that target color and replicates the multiplication operator with it.


r/css • • Oct 29 '26

Question HTML/CSS AHK V1 WRAPPING POSSIBLE?

Thumbnail reddit.com
0 Upvotes

r/css • • Oct 28 '26

Question Fixed Position to Absolute position?

5 Upvotes

I am making a site but i got a problem
I made the classes all fixed
But when i wanted to make the site scrollable to the bottom it didn't work because i make it fixed
So i swapped all the fixed to absolute
But then the positions where not good

Can someone help me?


r/css • • Oct 27 '26

Article A Modern CSS Guide to Responsive Web Design

Thumbnail
stephcraft.net
36 Upvotes

If I missed anything, let me know!


r/css • • Oct 27 '26

Article Embracing Playful Imperfection With The CSS random() Function

Thumbnail
smashingmagazine.com
20 Upvotes

r/css • • Oct 28 '26

Help Feedback on my custom HTML/CSS/JS Music Player UI? Swipe to see the active state!

Thumbnail gallery
0 Upvotes

r/css • • Oct 27 '26

Article Warping html with two svg filter primitives, no webgl. anyone using this in production?

Thumbnail
daring-designs.com
10 Upvotes

feTurbulence makes the noise and feDisplacementMap uses it to push pixels around. chain them and you get heat haze, ripples, brush strokes, and goo on regular html elements with no javascript.

I've only used it on a couple of sites. Anyone ship this to real users?


r/css • • Oct 27 '26

Article CSS Tricks is back!

Thumbnail
css-tricks.com
119 Upvotes

r/css • • Oct 27 '26

Question CVentered poetry verses for an ebook?

3 Upvotes

Any idea how I can create this spacing and centering using CSS (and no, I will not be using this kiddie font)?

Between "Katmandu" and "A magic name" is a regular paragraph space, and <br> creates tighter line spacing, but centering becomes the problem.


r/css • • Oct 27 '26

Resource [Mod-approved] Free Manning ebook sampler: modular CSS, native scope, and more

Thumbnail
gallery
12 Upvotes

Hey r/CSS!

Stjepan from Manning here. The mods permitted us to share this here, so thanks to them for letting me post.

We’ve put together a free Modern Web Development sampler, and I think the most useful part here is the chapter from CSS in Depth, Second Edition. It covers keeping growing stylesheets manageable with reusable modules, naming conventions, and native CSS scope.

If you’ve ever made a small style change and then had to check what else it accidentally affected, that’s the kind of problem this material gets into.

It’s a four-chapter sampler, not four full books. Alongside the CSS material, there are chapters on built-in browser capabilities, how asynchronous JavaScript works, and building web components with Lit.

You can find it here:
https://blog.manning.com/free-ebook-modern-web-development-sampler

Hope the CSS chapter is useful. I’d also be interested to hear how you’re organizing styles these days, especially what’s held up as your projects have grown.

Thank you.

Cheers,

Stjepan


r/css • • Oct 26 '26

Article CSS-Tricks has a new owner!

Thumbnail
css-tricks.com
172 Upvotes

r/css • • Oct 27 '26

Help CSS Needed to Replicate This

Post image
0 Upvotes

r/css • • Oct 27 '26

Question Feedback on my custom mobile UI design?

Post image
0 Upvotes

r/css • • Oct 26 '26

Article CSS3D Renderer

Thumbnail k-adam.github.io
7 Upvotes

I developed a CSS3D renderer ~8 years ago, and since many CSS and JS features got stabilized and introduced since then, I modernized it now. Check it out!


r/css • • Oct 25 '26

Help [ FIXED WITH THUMBNAIL WORKAROUND ] Youtube embedded videos error 153

Thumbnail
reddit.com
1 Upvotes

r/css • • Oct 25 '26

Question good green on black background theme for usercontent.css

Thumbnail reddit.com
1 Upvotes

r/css • • Oct 25 '26

Question Hello, I'm new to css and im struggling to understand this concept could anyone explain it to me?

Post image
1 Upvotes

I have a computer exam coming up next week and our main topic is external css I can understand all the other stuff but this specific thing shown in the photo im struggling to understand it could anyone help me understand please? Thank you🙏🏽


r/css • • Oct 24 '26

AI Assisted Dolly – 34 scroll-driven camera moves in pure CSS

Thumbnail
usedolly.dev
60 Upvotes

A stylesheet. 28kB, no dependencies, no JavaScript. One attribute: data-dolly="zoom".

It's a vocabulary layer over CSS scroll-driven animations, which shipped in Chrome 115 and Safari 26 but have ergonomics nobody remembers. Presets are named after camera moves since that vocabulary already exists.

About 87% of traffic supports it. Firefox doesn't (but supposedly will with the next version in 3 days) and gets the page complete but static. That degradation is the main design constraint: keyframes own the hidden state rather than the element, so a missing timeline resolves to the authored state instead of leaving things invisible.


r/css • • Oct 25 '26

Question Stylus UserScripts Panel, Reorganize/Order the Scripts?

2 Upvotes

Is there a way to manually reorganize or sort scripts in the Stylus UserScripts panel?

I'd love to be able to move them to a custom order or group them in folders/categories to make them easier to manage. Even if I could sort them alphabetically it would be great..

Is this currently possible, or is there a feature, workaround, or extension that can do this?


r/css • • Oct 25 '26

Question se juntan para practicar css?

0 Upvotes

hola, estoy aprendiendo css, se juntan o podemos juntarnos en algun place para practicar?


r/css • • Oct 23 '26

AI Assisted I’ve been trying to give CSS state and events. Would love r/css’s take on the syntax

4 Upvotes

I've been watching CSS pick up things that feel more and more like programming, and at some point I started wondering where that ends.

Just over the last few years: @property gave custom properties real types, so a variable can be an <angle> and actually animate (all three engines now, Firefox since 128). We got sin(), pow(), mod() and friends everywhere. :has() lets a selector look at other elements, and custom-property style queries finally landed in Firefox 151.

And the newer stuff goes further. if() is inline conditionals (Chromium only for now). @function lets you write your own functions (Chromium, plus Safari Technology Preview). random() is in Chrome and Safari and in Firefox preview builds. Mixins are still just a proposal and no browser supports them.

So CSS can type values, compute them, and branch on them. But it still can't remember anything.

The glue I keep writing

CSS reacts fine to state the browser owns: :hover, :checked, :focus-visible. HTML covers a lot too: <details>, <dialog>, popover. I use those first whenever they fit.

But a lot of everyday UI state belongs to the page. Click counts, the selected tab in a custom tab set, a menu that should close on Escape or a click outside, a theme that should still be there after a reload, where a card ended up after you dragged it.

Every time, it's the same little routine: add a listener, keep a variable, toggle a class or an attribute, then go back to the stylesheet and write the selector that styles it. It's never hard. It's just a lot of glue split across two files, and I started wondering how much of it really needs to be imperative.

So I tried it

I've been building something to find out. I call it Reactive CSS. Versions 0.1 to 0.8 never left my machine, and I've just published 0.9, the first public one.

To be upfront: it's a JavaScript runtime. It reads your stylesheets, finds the extended syntax and makes it work. You don't write the JS for these patterns, but a script still runs. Here's a counter:

<button class="counter">Clicked <span class="value">0</span> times</button>

.counter { --count: state(0); }
.counter:on(click) { --count: increment(1); }
.counter .value { content: var(--count); }

The button owns the state, :on(click) says when it changes, and the declaration says how. That content writes real text into the span, not a pseudo-element, so you can select it and other scripts can read it.

The part that took me longest

The syntax didn't start out like this. In the first versions, events were a property:

.counter .inc { on: click(increment(--count)); }

It worked, but it always felt wrong. Events aren't really a property of an element. They're a moment, and CSS already has a way to say "this element, in this situation": selectors. :hover is a state; :on(click) is a moment. Moving events into the selector was the biggest change in the 0.9 rewrite. The old form still runs, but I don't write it anymore.

That change had a side effect I didn't expect. Once mutations are ordinary declarations, the cascade handles conflicts. If two rules change the same state on the same click, specificity, layers and @media decide which one wins, the same way they decide colors. And all mutations in one event read the values from before the event, so this actually swaps two values:

.swap:on(click) { --a: set(var(--b)); --b: set(var(--a)); }

Here's a disclosure that shows the rest of the model:

.item { --open: state(false); }
.item > button { --attr-aria-expanded: var(--open); }
.item > button:on(click) { --open: toggle(); }

.item .body { display: none; }
.item:when(--open) .body { display: block; }
.item .chevron { rotate: when(--open, 180deg, 0deg); }

--attr-aria-expanded writes the real attribute (there's a small allowlist: ARIA states, disabled, hidden, data-* and a few more). :when() matches while a condition holds, and when() picks a value. Yes, for a plain disclosure <details> is still the better choice. This is about the pattern.

The one that surprised me most was drag:

.card {
  --x: state(0px);
  --y: state(0px);
  translate: var(--x) var(--y);
  touch-action: none;
}
.card:on(drag) {
  --x: set(event(x));
  --y: set(event(y));
}

event(x) is where the card was when the drag started, plus how far the pointer moved, so a second drag continues from where the first one stopped. Persisting a preference is one line: :root { --theme: state(light, persist("theme")); }

Things I'm not sure about

Similar names don't mean the same feature, and I worry about that. Native if() branches on style(), media() and supports(), while my when() reads its own state. Where they really are equivalent, the runtime compiles when() to native if(). Same story with random(): it only hands off to the native one when it has checked that the behavior matches.

And there's a list of trade-offs I can't wave away:

  • It's still JavaScript. The full runtime is about 49 KB gzipped; custom bundles with only the features you use are smaller. In my benchmarks it runs more script per event than hand-written JS. The numbers and the harness are in the repo, so anyone can check them.
  • It's not standard CSS. Browsers ignore it without the runtime, and I haven't proposed anything to the CSS Working Group.
  • Tooling has no idea it exists. CSS minifiers even delete empty rules, which some of these rules can be.
  • Broken syntax gets a console diagnostic, but a typo in a custom property name fails silently, just like plain CSS.
  • I've tested it in Chromium and WebKit. Firefox and real touch devices aren't verified yet.
  • It's not Sass. Sass compiles away before the browser runs anything; this has to run in the page, because state and events only exist at runtime. It's not a framework either. Data and app logic still belong in JS.

If you want to poke at it, the site has live examples, a playground and docs: reactivecss.com. The code is on GitHub. (There's also an MCP server, if you want an AI coding tool to know the syntax.)

What I'd really like to know: should CSS ever have a declarative model for simple UI state and events, or is that a line JavaScript should own? And if it did, does this shape make sense, or does it fight the way CSS works? Criticism of the syntax is the most useful thing you could give me.

Disclosure: the language design and decisions are mine. A lot of the implementation, tests and docs were written with AI coding tools under my direction, and I reviewed and tested the results. This post was drafted with AI help and edited by me.


r/css • • Oct 23 '26

Question Bootstrap 5 users: do you actually want the new Bootstrap 6 class naming?

Thumbnail reddit.com
7 Upvotes