Why doesn't the background image show up without specific width and height?

后端 未结 5 2002
星月不相逢
星月不相逢 2020-12-16 16:24

Here\'s an example code

I\'ve been wondering why the background-image doesn\'t show up unless I specific the image\'s width and height in pixels. I trie

5条回答
  •  春和景丽
    2020-12-16 16:59

    Your

    element don't have any content, so the
    height is 0px.
    The width of the
    is still 100%.
    If you add any content to the div it will have some height and it will show a portion of image.
    by default has the height of the window, so you can see the background-image.

提交回复
热议问题