How is padding-top as a percentage related to the parent's width?

后端 未结 5 2111
[愿得一人]
[愿得一人] 2020-11-29 05:35

Here is an example:

http://jsfiddle.net/QZAd8/1/

Notice how all of the red divs are the same height and have padding-top:100%;, yet

5条回答
  •  佛祖请我去吃肉
    2020-11-29 06:04

    It's true that padding percentage is relative to the width, but specifically, padding: 100% can also be read as padding: *width-of-container*px.

    The A and C blocks had a width of 70px. Applying padding: 100% was the same as padding: 70px

提交回复
热议问题