Why don’t top and bottom `auto` margins center things?
CSS adds vertical centering in 2024
21–30 of 50 posts
Re: CSS adds vertical centering in 2024
#22This was already a feature for flex box and grid. They’re just adding this to flow layout. Still a welcome addition but consider that all browsers that add support for this will already have support for flex and grid.
Re: CSS adds vertical centering in 2024
#23Re: CSS adds vertical centering in 2024
#24This was already a feature for flex box and grid. They’re just adding this to flow layout. Still a welcome addition but consider that all browsers that add support for this will already have support for flex and grid.
Bizarre that a statement of fact is being voted down.
Re: CSS adds vertical centering in 2024
#25But what about all the Vertical Centering as a Service providers that is going to put out of business??!
Re: CSS adds vertical centering in 2024
#26Earlier quoted context omitted.
Per the article, _align_ is for vertical distribution, and _justify_ is for horizontal. The example is actually behaving correctly. The naming is confusing though, imo
Ah! Thanks for the correction. Unfortunately it's not centered vertically either. It's in the top left.
Re: CSS adds vertical centering in 2024
#27Why don’t top and bottom `auto` margins center things?
Doesn’t seem like that would play nice with margin collapsing, like what if you had two box elements with that style that would otherwise undergo margin collapsing, how should they render? What’s the baseline margin to combine if they should collapse and what’s the baseline margin to separate them if they shouldn’t?
Even with all the cool layout props we have today, it’s way too complicated to say „make this thing fill the whole screen minus the navbar at the top, make it scrollable if the content overflows and Center it vertically otherwise“. Add a grid or sticky elements or z index modifications to the mix, and the quirks get loud fast.
Re: CSS adds vertical centering in 2024
#28This was already a feature for flex box and grid. They’re just adding this to flow layout. Still a welcome addition but consider that all browsers that add support for this will already have support for flex and grid.
Re: CSS adds vertical centering in 2024
#29It seems odd that "style sheets" turned into layout language. ;-)
Re: CSS adds vertical centering in 2024
#30This was already a feature for flex box and grid. They’re just adding this to flow layout. Still a welcome addition but consider that all browsers that add support for this will already have support for flex and grid.