0

For background-size, we can use percentage, setting the width and height of the background image in percent of the parent element. Now if the html goes like this:

<section>
    <p>Background-size by percentage.</p>
</section>

and I set up background image for <p>. Now which one is the parent element of the background image, <p> or <section>? Thanks.

uoay
  • 306
  • 2
  • 13

1 Answers1

1

Parent element means the background image's parent. It's <p>.

Try to set different width on <p> and <section>, like width: 500px and width: 1000px

You will get it.

TsaiKoga
  • 12,914
  • 2
  • 19
  • 28
  • Yes. Thanks for that. By the way, I discover that so far, width and height by percentage is all based on the parent element. Is it correct? Perhaps I haven't come across an exception. – uoay Nov 12 '19 at 04:15
  • Yes. and ```parent``` can be changed by the value of ```postion```. – TsaiKoga Nov 12 '19 at 05:39