.net Core 3.1 错误 404 在 css 中添加背景图像 [英] .net Core 3.1 error 404 adding background-image in css
问题描述
查看:
<div id="div2">佩奇
<风格>#div1 {背景图片:url('/images/Peppa.jpg');宽度:279px;高度:181px;}#div2 {背景图片:url('/images/green.PNG');宽度:100px;高度:50px;}</风格>
结果:
I am getting error 404 (in console) when adding background-image: url("/wwwroot/images/bg-01.jpg");
What i did was to remake the login page with a template, and it's all working. But cant add image to background.
I have a template with pure css and html and js in notepad that is working.only when passing to .net core. the image is with error. In view i am not using _Layout The path is correct since i tested touse in a img tag with href:/wwwroot/images/bg-01.jpg and it works fine. I also tried to use an correct url image from web and same error Anyone can help.?
You need to use like url('/images/bg-01.jpg')
,here is a demo:
wwwroot:
view:
<div id="div1">
<div id="div2">
Peppa
</div>
</div>
<style>
#div1 {
background-image: url('/images/Peppa.jpg');
width: 279px;
height: 181px;
}
#div2 {
background-image: url('/images/green.PNG');
width: 100px;
height: 50px;
}
</style>
result:
这篇关于.net Core 3.1 错误 404 在 css 中添加背景图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!