I have a stylesheet defined in the index.html as
<link rel="stylesheet" type="text/css" href="css/template.css">
Inside the template.css, I have declared
body{
background-image: url(images/background.png);
b开发者_如何学Cackground-repeat: repeat;
}
Why is the image not getting displayed? The path is correct
The path in the CSS should be relative to where the CSS file is located, not from where the page where the CSS file is being loaded from.
Try:
background-image: url(../images/background.png);
When you are starting out, this can seem counter intuitive, but it's actually a good design as your CSS file can then be called from any page in any folder and the references to the images will not be broken.
精彩评论