November 13, 2019 10:05 pm GMT
Original Link: https://css-tricks.com/oh-hey-padding-percentage-is-based-on-the-parent-elements-width/
Oh Hey, Padding Percentage is Based on the Parent Elements Width
I learned something about percentage-based (%) padding
today that I had totally wrong in my head! I always thought that percentage padding was based on the element itself. So if an element is 1,000 pixels wide with padding-top: 50%
, that padding is 500 pixels. It's weird having top padding based on width, but that's how it works — but only sorta. The 50% is based on the parent element's width, not itself. That's the part that confused me. … Read article
The post Oh Hey, Padding Percentage is Based on the Parent Element’s Width appeared first on CSS-Tricks.
Original Link: https://css-tricks.com/oh-hey-padding-percentage-is-based-on-the-parent-elements-width/
Share this article:
Tweet
View Full Article