问题
Imagem Erro
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.?
回答1:
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:
来源:https://stackoverflow.com/questions/64416647/net-core-3-1-error-404-adding-background-image-in-css