开发者

MVC CSS Default Colour

I've created a default MVC app, and want to change the background colour of the main form. I go into the Site.css and change the following section:

body
{   
    background-color:Black;
    font-size: .75em;
    font-family: Verdana, Helvetica, Sans-Serif;
    margin: 0;
    padding: 0;
    color:White;    
}

Then, when I view the Site.Master in design mode, it shows with a back background and white text.开发者_C百科 However, when I subsequently run the app, it reverts to the default colours. I can force the colour change by simply adding a style tag to the body:

<body style="background-color:Black">

And that works fine. The CSS file seems to be wired up correctly:

<head runat="server">
    <title><asp:ContentPlaceHolder ID="TitleContent" runat="server" /></title>
    <link href="../../Content/Site.css" rel="stylesheet" type="text/css" />
</head>

What am I doing wrong / missing?


Make sure the path to your stylesheet is correct. ../../ will only work when you're two folders deep relative to the root.

<link href="<%=ResolveUrl("~/") %>Content/Site.css" rel="stylesheet" type="text/css" />
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜