简体   繁体   English

div中未显示背景图片

[英]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 , 尝试以下代码,将background更改为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 . 尝试使用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 . 使用background-image而不是background

The background css logic seems to be fine. 后台CSS逻辑似乎很好。 Then you should check that the div is being shown has the proper size with the browser's inspector (has it got width...?) 然后,您应该使用浏览器的检查器检查显示的div大小是否正确(是否有宽度...?)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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