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

后端 未结 5 1768
不思量自难忘°
不思量自难忘° 2020-12-16 16:15

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:45

    If you don't specify height, the size of your div is given by the size of its contents, i.e. it's 0x0, so you don't have much chance of seeing a background image. Add

    border: 1px solid red;
    

    to see how large your div is (or isn't).

提交回复
热议问题