Post

πŸ’‘ CSS Tip! We've just had the release of @developer.chrome.com 147, which means border-shape was enabled by default! πŸ‘€ css-tip.com/border-shape/ Another property to create CSS shapes, but not only that! We can do a lot of fancy stuff with it. Many cool demos/articles are on the way 🀩

11 reposts43 likes

You can rectify the last example using an inset box-shadow `box-shadow: 0 0 0 999px inset var(--color)` But I'd rather adjust the code to make the shape "inside" the boundary of the element if you want to use border-shape.

Oh, clever! Did not know an inset box-shadow could do that. I did consider just moving it inside the content area, but I kinda like it physically jotting out of the element. In a real world scenario if it weren't sticking out I'd probably need to compensate for it in terms of margins all the time.

This honestly feels like the biggest revolution in web browsers since mosaic to me... true non-rectangular elements? Sure we had ways to do clipping and rounded corners and such, but in the end they were always just rectangles

There are still rectangles considering the flow and their content but at least the decoration is now following the non-rectangular shape.

There is a half-spec for it but it's really problematic in terms of overflow (what's the right way to overflow from a heart shaped text?), and in general for readability you mostly want to pad your text rather than shape it like the decoration around it.