We have in the past used a straight .aspx page for our "dynamic" css.
We have a core set of CSS, but we need to display different areas of the site in different colours for branding/helping users distinguish between different sections etc.
The main thing you'll want to do is sort out the response encoding:
private void Page_Load(object sender, System.EventArgs e)
{
Response.ContentType = "text/css";
}
Then on the code in front:
<%
string strSiteArea = this.Page.Request.QueryString["sitearea"];
string strCustomStyles = this.Page.Request.QueryString["customcssstyles"];
string extralightcolour = "";
string lightcolour = "";
string normalcolour = "";
string darkcolour = "";
string customcolour = "";
switch (strSiteArea)
{
case "miscellaneous":
extralightcolour = "#F2F2F2";
lightcolour = "#E6E6E6";
normalcolour = "#999999";
darkcolour = "#666666";
break;
case "pressoffice":
extralightcolour = "#F0F4F7";
lightcolour = "#E2E9EE";
normalcolour = "#6D8DA8";
darkcolour = "#5C768D";
break;
// etc
}
%>
h1{color: <%= darkcolour %>;font-family: Arial;padding-left: 0;margin-left: 0;}
h2{color: <%= darkcolour %>;font-family: Arial;font-size: 1.2em;font-weight: bold;margin-bottom: 0;padding-bottom: 0;}
h3{color: <%= darkcolour %>;font-size: 1.1em;font-weight:normal;margin-bottom: 0;}
h4{color: <%= darkcolour %>;margin-bottom: 0;font-size: 1.1em;font-weight:normal;font-style:italic;}
.backgroundheading{margin: 0 0 0 0;background-color: <%= normalcolour %>;color: #FFF;font-weight: bold;font-family: Arial;font-size: 1.0em;text-align: left;padding: 3px 5px 3px 5px;}
.backgroundheadinglight{margin: 0 0 0 0;background-color: <%= lightcolour %>;color: #000;font-weight: bold;font-family: Arial;font-size: 1.0em;text-align: left;padding: 3px 5px 3px 5px;}
.backgroundheadingdark{margin: 0 0 0 0;background-color: <%= darkcolour %>;color: #FFF;font-weight: bold;font-family: Arial;font-size: 1.0em;text-align: left;padding: 3px 5px 3px 5px;}
.background{margin: 0 0 0 0;background-color: <%= normalcolour %>;text-align: left;padding: 3px 5px 1px 5px;}
.backgroundlight{margin: 0 0 0 0;background-color: <%= lightcolour %>;text-align: left;padding: 3px 5px 1px 5px;}
.backgrounddark{margin: 0 0 0 0;background-color: <%= darkcolour %>;text-align:left;padding: 3px 5px 1px 5px;}
.backgroundcolorextralight{background-color: <%= extralightcolour %>;}
And then call the CSS in a page such as:
<link rel="stylesheet" href="/CSS/GenerateCss.aspx?siteArea=pressoffice" />
This gave us the power to have a number of different colour schemes using a consistent set of CSS styles, and change a page with ease based on the querystring passed in.