1

I'm trying to load an image as a background image as a responsive background image. but the image isn't loading. here is my CSS code.

.cover{
    height: auto;
    width: 100%;
    background-image: url(../img/cover.jpg);
    background-repeat:no-repeat;
    background-size:contain;
    background-position:center;
}
Hasitha
  • 67
  • 2
  • 9

1 Answers1

1

If the div doesn't has content then its height will be 0px,So the background image is not displayed. Try giving height as 350px say or 100vh . you can check the div height by giving border.Ref this Why doesn't the background image show up without specific width and height? for more details,hope it helps

Deepak A
  • 1,624
  • 1
  • 7
  • 16
  • The issue was div tag not having a value. I applied height as height: 100vh; and it worked fine. Thank you. – Hasitha Apr 27 '19 at 05:00