Interactive online courses HTML Academy
2026-03-09 14:12 Diff

We can achieve an interesting effect by combining a flexbox and a trick with the :checked ~ selector.

The method works as follows: you can use the checkbox selector to control the order of flex items by changing the direction of the main axis using flex-direction. The effect works best when the direction of the main axis changes from “top to bottom” to “bottom to top”.

In this case, the flex container should be on the same level in the markup as the checkbox.

Thus, we can achieve CSS sorting without having to use JavaScript.