3

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. 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?

2
  • So you're saying it works correctly on your IDE but defaults when deployed? Have you tried using an absolute path to your css? Commented Mar 31, 2011 at 18:09
  • have you tried clearing cache and refreshing the browser? css could be cached by your browser. Commented Mar 31, 2011 at 18:11

1 Answer 1

3

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" />
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.