Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 640
Paul Michaels Avatar asked Jan 27 '26 16:01

Paul Michaels


1 Answers

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" />
like image 115
hunter Avatar answered Jan 31 '26 01:01

hunter