css - Not able to add Background Image on Position Absolute div -


can please take @ this demo , let me know why not able add image #img-box

html, body {     height:100%;     width:100%; } #wrapper {     position: relative;     height: 100%;     width: 100%; } #img-box {     position: absolute;     background-image: url("http://www.bluearthrenewables.com/wp-content/uploads/2014/12/7_intake-construction_cullitoncreek.jpg");     top:0;     left:0;     background-size: cover;     background-repeat: no-repeat;     background-attachment: fixed; } 

because #img-box has not width & heights associated it. try define

html, body {      height:100%;      width:100%;  }  #wrapper {      position: relative;      height: 100%;      width: 100%;  }  #img-box {      position: absolute;      background-image: url("http://www.clker.com/cliparts/2/0/f/b/13873752061098664878happy_smiley-th.png");      height: 100%;      width: 100%;      top:0;      left:0;      background-size: cover;      background-repeat: no-repeat;      background-attachment: fixed;  }
<div id="wrapper">      <div id="img-box"></div>      <div id="tets"></div>      <div id="tes3"></div>  </div>


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -