livellosegreto.it is one of the many independent Mastodon servers you can use to participate in the fediverse.
Livello Segreto è il social etico che ha rispetto di te e del tuo tempo.

Administered by:

Server stats:

1.3K
active users

#csslayout

4 posts2 participants0 posts today

Flexy flex layout for any number n of items such that we have:

👉 at most 3 items on a row
👉 at least 2 items on a row IF we have at least 2 items in total

In only 5 (display, flex-wrap, gap, flex and flex-basis override) CSS declarations, working for any number n of items! 🎇

Because someone asked for this on reddit reddit.com/r/css/comments/1jay

Here is the @codepen demo codepen.io/thebabydino/pen/OPJ

#CSS#flexbox#layout

Someone asked (yet again) on reddit for that inverted radius tab pattern so here's a pure #CSS solution from me reddit.com/r/css/comments/1ior

✨ no extra elements or pseudos needed for effect
✨ only need to set border, background, border-radius

If you also want borders, I made another (hopefully accessible) tabs pattern demo using #SVG #filter and #subgrid to answer another reddit question last year reddit.com/r/css/comments/1fwl

#tinyCSStip if you want to make an absolutely positioned pseudo cover its parent's entire `padding-box`, use `inset: 0`!

(love grid for stacking/ full coverage too, but there are differences between how the two solutions work and there are cases when absolute positioning is still preferable)

#CSS#code#coding

Saw youtube.com/watch?v=An3QMWg3m1c linked last evening & gave the challenge a quick go myself.

My approach was a mostly #CSS one, with minimal HTML (no extra wrappers) and JS (used only to update top item index, ~200 bytes minified).

While it was working, it wasn't pretty, so today I polished the demo & heavily commented the CSS - check it out on @codepen: codepen.io/thebabydino/pen/jEN

Continued thread

Back in '15, I had 16 cube elements, each with 3 descendants.
Now I have 16 empty cube elements.
I went from 64 descendants inside the grid element to just 16.

Back in '15, I was stacking all absolutely positioned cube elems in the middle, looping through them all to manually compute their grid positions incl. gaps, put them in the right place using translate(). This bloated compiled CSS.

Now I just use #CSS grid, no looping necessary!