Joseph izz
Joseph izz

Reputation: 23

Background image not showing in ASP.NET Core

I am trying to add a background image to my ASP.NET Core application, but it's not showing.

Even a normal is not showing.

<div class="landing">
    <div class="text-center">
        <h2> app</h2>
        <h4>blah </h4>
        <button class="btn-success">See what we have</button>
    </div>
</div>
<style>
    .landing {
        background-image: url(..\..\wwwroot\images\bkimage.jpg);
        background-repeat: no-repeat;
        background-attachment: fixed;
        background-size: cover;
        height: auto;
    }
</style>

Upvotes: 1

Views: 2348

Answers (2)

mahdieh shabani
mahdieh shabani

Reputation: 1

Height attribute must be quantified. For example: height:400px.

Upvotes: 0

Adam
Adam

Reputation: 3847

I'll assume the snippet above is from an MVC view. When you're using the wwwroot folder, that represents the static content root against which other things can reference (unless you've explicitly changed that). So, the 'wwwroot/images/bkimage.jpg' would just be the root-relative path '/images/bkimage.jpg' off that.

Try the following:

background-image: url('/images/bkimage.jpg'); 

Upvotes: 4

Related Questions