开发者

Visual Studio 2010 Not Linking CSS File

I currently have a css file that I want to link in visual studio. I have included the file in my project yet it is still not working.

I am simply using css to change the body background. Here is my code:

Css - folder: /css/Style.css:

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

Html

<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title>My Website</title>

        <link rel="stylesheet" type="text/css" href="css/Style.css" />
    </head>

    <body>
        <div id="header">
        </div>

        <div id="page-wra开发者_运维知识库p">
            <ul id="nav">
                <li><a href="#">Link</a></li>
                <li><a href="#">Link</a></li>
                <li><a href="#">Link</a></li>
                <li><a href="#">Link</a></li>
                <li><a href="#">Link</a></li>
            </ul>

            <p>Main Content</p>
        </div>

        <div id="footer">
        </div>
    </body>
</html>

It all works perfectly when I put the style internally in the head it works perfectly. What's going on?


The link in the css file to your image is relative to the css file.

try

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

to get it from root, or

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

to get it relative to the css file.


This will work in css file.

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜