I'm sure it's a simple fix. I just don't see it. I tried the solutions I saw online but neither worked in my case.
What I'm trying to do:
set background to my <body>
What my code is doing:
<img>
in my <body>
under my hello world.<head>
<style>
body{
background-image: url("~/images/indeximg0.jpg");
margin:0;
</style>
</head>
<body>
hello
<br>
world
<br>
<img src="~/images/testrootimg.jpg" alt="">
</body>
What I tried:
(1)
url("~/images/indeximg0.jpg")
to url("../../wwwroot/images/indeximg0.jpg");
However my test image after the <br>
also disappeared
(2)
<body style="background-image: url(~/images/indeximg0.jpg)">
made no difference
additional information:
Can it help you? This is my testing result
<style>
body {
background-image: url("/images/bg1.png");
}
</style>
By the way, if you're using asp.net core and using _layout in your project, then you wanna set consistent background image for your site, you should set the style in your _Layout.cshtml.