Search code examples
asp.netcssimagebackgroundbackground-image

Background image not showing in asp.net project


I have created ASP.NET project in my office computer and synchronized it using Google Drive, so that I can open the same project in my home.

Both my office computer and home computer have the same resources.

I have executed the same project in my home computer, the background image of the web page not displayed.

Below is the css code I used to display the background image

body { 
    background-image: url('/Images/blue.jpg');
}

Also I have tried,

body { 
    background-image: url('../Images/blue.jpg');
    background-image: url('~/Images/blue.jpg');
}

I don't know what causes the problem while opening ASP.NET projects on different machines.


Solution

  • Try by giving the full path for the image

    eg:

    body { 
    background: url('http://www.australia.com/contentimages/about-landscapes-nature.jpg');
    }
    

    If it is working, then the problem is with your path, so you have to correct it.

    To correct the path:

    1) Take the image out of the folder put it in the folder in which stylesheet lies

    2) Give style as background-image: url('blue.jpg');