Wednesday 18 March 2020

Flexbox and absolute positioning

Chen Hui Jing notes that when you absolutely position a flex item, it's no longer part of the flex layout. Except... it kinda is a little bit. If you make the child position: absolute; but don't apply any top/right/bottom/left properties, then flexbox alignment will still apply to it.

It's odd to see, but it makes a certain sort of sense as well. When you apply position: absolute; to things (and nothing else), they kinda just stay where they are until you apply other positioning. Check out how this SVG icon just sits in the middle of this paragraph, and even flows with it on resize, because it doesn't have any specific positioning instructions other than to not affect anything else.

Direct Link to ArticlePermalink

The post Flexbox and absolute positioning appeared first on CSS-Tricks.



from CSS-Tricks https://ift.tt/3d0Awxo
via IFTTT

No comments:

Post a Comment

Passkeys: What the Heck and Why?

These things called  passkeys  sure are making the rounds these days. They were a main attraction at  W3C TPAC 2022 , gained support in  Saf...