Post

❓ A question for web developers ❓ If you do layout in CSS, what's missing? I'm especially interested in hearing about use cases that aren't yet solved by existing CSS layout features. #css #webdev

18 reposts24 likes

A version of `width: fit-content` that only takes the actual space it needs for wrapped text. So in the example here, I'd like the message box to fit the text and not have the extra space at the right side. This should also work with text-wrap `pretty` and `balanced` ;)

I'd also love support for 'auto' in `max()`, `min()`, etc. This is useful for flex layouts where a child should justify at the end, but always have a minimum margin: ```css margin: max( 8px, auto ); ```

detecting when things have overflow, and perhaps things work like a media/container query. this is crude: .my-div::has-overflow-y { (other declarations and selectors) } i think there's some stuff you can do with scroll-driven animations in Chrome but that seems overly complex

The ability to do `border-offset` (similar to `outline-offset`). I know we can use box shadow, but it's a hack and doesn't work w forced colors.

Alternatively, the ability to do outline-left etc (similar to border-left) would be nice. Outline is nice because it doesn't affect the box sizing like border does.

The (still experimental) border-shape attribute can or rather might be used for that. It actually just effects the border and not the fill of the border. bsky.app/profile/g12n...

Michael G@g12n.de

How did you extend the background of of the element to with the out facing arc? In my experiments only the border extends beyond the original object box. not the background.

- selectors like :overflows/ :wraps, e.g. to turn from a horizontal list to vertical. - curved text - full control over the design of gaps and empty cells in a grid (the current workaround used divs for gaps & empty cells) - automatic hitbox expansion - anchor positioning to start/end of textline

Circular layout and/or polar coordinates. Imagine a flexbox that curves around an origin point so that its x-axis edges meet. You could use it build pie-chart like layouts, for example.

Direct children count? Sure you can count siblings now and you can also "has-spam" it. But a children-count() calc function would be powerful especially combined with css conditionals.

Being able to select the n-th instance of wrapped lines, both with wrapped rows of flex items and with wrapped text lines, would open up a world, IMO. Like: even rows space-between and odd rows space-around, etc. Zebra striping, hide/expand row 2 and above. Etc.

Yes, with grid (and same sized columns), it’s possible. But how to do it with variable with elements in flex-box? How can I hide input fields on row >1 ? (Hide, because they should not be focusable)

I would love to see support for variables in container size queries. This is mentioned in the spec, but no browser vendor seem to have it on the radar right now.

+1 to overflow detection. Having a way to easily adapt layout such as allowing horizontal scrolling on mobile of panels etc. Sort of tied to this is content wrapping, such as a grid item being pushed to a new row. Being able to style it to span or centre etc.

I’ve been running into layout issues where it would be nice to assign content to a (different) slot, a bit like grid area. Combine that with overflow detection, and we are off to the races.

Same here.. With how much simpler css is these days, it would feel nitpicky to focus on marginal improvements I'm hardly an expert, but I get by and so far not found something I can't work around I'd love for 3rd party tools to stop reinventing the wheel with custom theming plugins though

Yeah, I'd love that. I currently accomplish this with JS but would love to cut that out, not that it's terrible or anything.

+1: when I needed to hide rows > 1 of a series of labeled dropdown filters, I ended up using a sass generated series of container queries based on the static filter-width. But what should I do if that width wasn’t fixed, but varying instead? Is there a way to only show row 1 of a wrapped flow?

This is something we’ve explored a few times but it creates infinite loops so idk if it’s really possible on the web. (Same with the overflow detection scroll state query when you try to use it for this use case). But I definitely hear the value in solving this 💯

A grid-area function for background-position would be nice. placing multiple backgrounds based on the elements css grid layout. Like placing a background behind a sidebar. Something typically done with generated content today and `z-index:-1` today. but that is limited to two elements max.

Do you you know the column start? In that case, you could compute the number of columns from the available parent width and the column width (we now have length division in CSS) subtract the column start from the number of columns and then use a min span. 🤔

I wish we were able to make sticky columns in a table without using JS, currently we have to take into account the width of all previously stuck columns to make it work. Maybe we can introduce some keyword, e.g. "left: additive", to let the browser know that we want to do calculations for us?

I want flow with grid-columns, and the ability to float-align into those columns, with text wrapping. like grid-lanes, but this time grid-flow. For editorial, article layouts, pull quotes, side notes etc

+1 to overflow detection (::overflows-x or so) Using Svelte here is ok due to reactive dom bindings but it’d be so nice to handle it without JS. Think: horizontally scrollable tabs in a narrow container. if tabs container overflows, I want to add a gradient overlay on the edge and maybe a button

"Teleporting" elements to other places. Typical example is a table of contents in a sidebar which should be displayed above the main content on mobile while the rest of the sidebar contents stay below. This is often not solvable with CSS grid alone and requires either JS or duplicate markup.

i want :has-slotted and new css stuff to consider shadow roots when being implemented permanently without us shadow root users having to beg for consideration after the fact anymore.