Live data from Hacker News

What does 100% mean in CSS? (2020)

wattenberger.com

21–30 of 72 posts

Re: What does 100% mean in CSS? (2020)

#21
post #2

and the interesting "trick" I learnt the other day for fixed/absolute positioning, if you add inset:0rem; margin: auto; it will center vertical and horizontal it without having to translate it courtesy of Kevin Powell - https://www.youtube.com/watch?v=HOM47v73yG8 ( who I've found to be an amazing resource for learning all kinds of CSS info )

Note that inset is a very recent introduction, only supported by Firefox 66+, Chrome 87+ and Safari 14.1+ (14.5+ in iOS). It will take quite a while to use it without thinking.

Tooling can take care of these things, letting you write in the logical property style and translating it into the physical property style for compatibility.

e.g. https://github.com/csstools/postcss-logical

Re: What does 100% mean in CSS? (2020)

#22

I'm a little embarrassed to admit that I've been working with this stuff for decades and I just now found out that margin and padding top is based on parent width if expressed in percentages. I'm only a little embarrassed because who expresses margins in percentages anyway.

It sure is useful when hacking together “always-square”, responsive elements.

But otherwise you’re right, it doesn’t really come up.

Re: What does 100% mean in CSS? (2020)

#25
post #18

I'm a little embarrassed to admit that I've been working with this stuff for decades and I just now found out that margin and padding top is based on parent width if expressed in percentages. I'm only a little embarrassed because who expresses margins in percentages anyway.

You never needed to set some flexible containers dimensions to have some precise aspect ratio? Up until very recently [1] the "padding hack" used to be the only option… https://css-tricks.com/aspect-ratio-boxes/ [1] Recently `aspect-ratio` got into evergreen browsers: https://developer.mozilla.org/en-US/docs/Web/CSS/aspect-rati...

Nope, never needed to do that. I've mostly only worked on some extremely unique use cases that use the browser in non-standard ways though (games, vehicle control, IDEs).

Re: What does 100% mean in CSS? (2020)

#29

This is why I knew how to be a frontend engineer at one point in life but never pursued it past the early 2000s. The brainpower wasted on web layout is immense.

Responsive design did this. Early 2000s there was only 1024 x 768px or a little above maybe.

Re: What does 100% mean in CSS? (2020)

#30

This is why I knew how to be a frontend engineer at one point in life but never pursued it past the early 2000s. The brainpower wasted on web layout is immense.

What about UI development is a waste?

That you have to redo it all the time, as in kitchen remodels.

Blame it on folks outside of dev? I would ban the word “modern” if possible. Everyone thinks that it’s obvious but no one seems to be able to define it once and for all, lol

Post reply on HN