For a long time now, I've always had to keep two copies of my CSS files - one for dev on my personal machine, and one for production on this live website. My reason for doing this has always been the "url()" property for setting a background image... I had to point the location of the image to the proper root folder, depending on which box was running the CSS at the moment.
But just recently, I found a great way to dynamically generate the location of the image, or any other part of the CSS file that I want: Give the css file a .ASPX extension and an @Page directive... once you've done this, you can write any code you want in ASP tags: <% %>.
I don't know how many other people have done this, but I know the guys over at TelligentSystems have done this with CommunityServer, which is where I stole the idea from. So, I'm actually using CS's code to create my url() tags at the root of my website, no matter where that root is: <%=CommunityServer.Components.Globals.ApplicationPath%>
And there you have it... dynamic CSS generating. Now I never have to worry about keeping 2 copies of a CSS file again. :)
As an example, where's what the first fiew lines of code look like in my .css.aspx file for this site:
<%@ Page AutoEventWireup="True" %>
<%@ OutputCache VaryByParam="fontsize;application" Duration="99999" %>
<%@ Import Namespace="CommunityServer.Components" %>
*{
FONT-FAMILY:Arial;
FONT-SIZE: 8pt;
}
BODY {
PADDING:0px;
PADDING-TOP: 46px;
HEIGHT:100%;
MARGIN:0px;
BACKGROUND: url(<%=CommunityServer.Components.Globals.ApplicationPath%>/skins/avocado2/images/background.jpg);
BACKGROUND-REPEAT:no-repeat;
BACKGROUND-COLOR: #DDDFC7;
TEXT-ALIGN: center;
}
The only reall "issue" with doing this, is that you lose your Visual Studio.NET Intellisense for CSS, and syntax highlighting. But i'm sure there are ways to get around this. I just haven't found them yet.