Shankhadeep Ghosal Shankhadeep Ghosal - 19 days ago 6
CSS Question

background-image :url(); not working

html:

<div id="banner">
<h1>My Page</h1>
<p>This is the important line everyone reads..</p>
<a href="#">Enroll</a>
</div>


css:

#banner{
background-image: url('https://usplash.it/1000/600/?random');/*problem is here*/
padding: 150px 0;
text-align: center;
background-size:cover;
color: white;
}


background-image: url('https://usplash.it/1000/600/?random')

This is not displaying any image . Not only for this link but for all other links.

Only if the image is downloaded and the path is given there as a link, then it is working.

Answer

seems like your link down is the cause. this one work

#banner {
  background-image: url(http://lorempixel.com/400/200);
  padding: 150px 0;
  text-align: center;
  background-size: cover;
  color: white;
}
<div id="banner">
  <h1>My Page</h1>
  <p>This is the important line everyone reads..</p>
  <a href="#">Enroll</a>
</div>

Comments