开发者

stylesheet reference issue

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜