简体   繁体   中英

Background image is not showing in the div

 .jumbotron { margin-bottom: 0px; height: 350px; color: white; text-shadow: black 0.3em 0.3em 0.3em; } 
 <div class="jumbotron" style="background: url('~/images/hdpic.jpg') no-repeat; background-size:cover"> </div> 

My image url is correct but i do't now why it is not working. if any one know please help me. Thanks.

Check your background image path, I've replaced the image path by another and it works.

Maybe replace the ' ~ ' by a relative path like ' ../ '

<div class="jumbotron" style="background: url('https://picsum.photos/200/300') no-repeat; background-size:cover">
</div>

See this fiddle

Try the following code, changed background to background-image ,

<div class="jumbotron" style="background-image: url('~/images/hdpic.jpg') no-repeat; 
background-size:cover">
</div>

Refer to this one . Try using background-image . See below:

 .jumbotron { margin-bottom: 0px; height: 350px; color: white; text-shadow: black 0.3em 0.3em 0.3em; } 
 <div class="jumbotron" style="background-image: url('~/images/hdpic.jpg') no-repeat; background-size:cover"> </div> 

Try this

<div class="jumbotron" style="background-image: url('~/images/hdpic.jpg') no-repeat; background-size:cover">
</div>

Use background-image instead of background .

The background css logic seems to be fine. Then you should check that the div is being shown has the proper size with the browser's inspector (has it got width...?)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM