aspdaddy

msg:1206364 | 11:51 am on Apr 26, 2003 (gmt 0) |
I did similar for an intranet in ASP, using a config file and some globals.e.g G_BGCOLOR = "#f5f5f5" Couldnt get it into the .css file so the next best thing was inline styles: <table style="background-color:<%=G_BGCOLOR%>"> Its not a great solution , a macro would be much nicer but I couldnt figure out how.
|
heini

msg:1206365 | 12:29 pm on Apr 26, 2003 (gmt 0) |
Jeremy, where do you see the advantage of globally changing "brown" over globally changing "#804040"? Also, a way to organize your sheets is to make as much central definitons as possible, which also has the effect of cutting down on the size of the sheets.
|
jeremy

msg:1206366 | 9:29 pm on Apr 26, 2003 (gmt 0) |
Hello heini, The advantage is that I would not have to do a global replace. I would only have to change it once - at the (eg #define Brown #804040 to #define Brown #CCCfff) and all instances where "Brown" occurs would change automatically and now be #CCCfff instead of #804040 This method is used in many languages (C pascal etc ) at the top of the file you have stuff like #define Brown #804040 #define MyEmail billG@microsoft.com and in the source you have something like..... Background-color = Brown; ... ... email = MyEmail; These may occur many times within the file. The advantage of a macro is that I do not have to find them, just change the definition at the top of the file (or included file) and the preprocessor or compiler does the rest for me. It is neat & tidy. I am not sure yet how sophisticated this CSS stuff is, I used to be a C,C++ programmer and old habits die hard. I will probably just move all things that I might want to change from time to time (like aesthetics) to a separate file like color.css and have the definitions there. At least they will be in one place.
|
grahamstewart

msg:1206367 | 2:39 am on Apr 27, 2003 (gmt 0) |
No there are no macro or define capabilities in CSS. I agree it might be handy in some cases, but it would lead to a whole new category of bugs too :) If you are really keen on coding like this then you could write your CSS in PHP. Like this... <?php header( 'Content-Type: text/css' ); define( 'BROWN', '#804040' ); define( 'PINK', '#daa'); ?> .myclass { font: <?php echo BROWN?>; background: <?php echo PINK?>; border: 1px solid <?php echo BROWN?>; }
|
| and then link to it as an external stylesheet in the normal way.. <link rel="stylesheet" type="text/css" href="styles.php"> To my mind this is a bit too clunky to use effectively so I can't really recommend it - but if you are already using a php stylesheet for other reasons (e.g. browser switching) then it might be useful to you.
|
|