0

this is my html markup:

<div class="main">

<div class="background">

</div>

</div>

this is the corresponding css:

body{margin:0;
padding:0;}

.main{width:100%;
height:auto;}

.background{width:100%;
background:url('../images/bg.jpg') no-repeat 50% 50%;
background-size:cover;
}

clearly the above code wont show any background image on my .background div.what i want is,i don't want to give height to my background div and want the background image on that div.

Ashish
  • 409
  • 1
  • 9
  • 24
  • Duplicated question: http://stackoverflow.com/questions/600743/how-to-get-div-height-to-auto-adjust-to-background-size – Tirma Mar 15 '16 at 16:02
  • does the background-image has a ratio (size known) and is it suppose to fill entire width ? ... background is nothing like content, it will not fill anything but will only be drawn on background , – G-Cyrillus Mar 15 '16 at 16:09
  • Using Background images on an element does not create height, therefore you're not going to see anything unless you specify a height, or add some html content which creates height in the DOM. You might be better off to insert your background image as an IMG element rather than a DIV with a background image. – Andrew-ThinkUp Mar 15 '16 at 16:14

0 Answers0