
Originally Posted by
AlistairH
Declaring Constants in a CSS file?
Is this possible?
No, but there are alternatives.
The first is to combine common declarations into a single rule with multiple selectors. Consider the snippet below, which was posted on Usenet recently:
Code:
.titlejgloss {
background : #91eaff;
border-color : #808080;
border-style : inset;
border-width : 1px;
display : block;
font-family : Arial,Helvetica,sans-serif;
font-size : 200%;
font-weight : bold;
padding : 5px;
margin-bottom : 10px;
margin-top : 0px;
}
.titlebgloss {
background : red;
border-color : #808080;
border-style : inset;
border-width : 1px;
display : block;
font-family : Arial,Helvetica,sans-serif;
font-size : 200%;
font-weight : bold;
padding : 5px;
margin-bottom : 10px;
margin-top : 0px;
}
The only thing that is different between them is the background property. It could be replaced by:
Code:
.titlejgloss,
.titlebgloss {
border: 1px inset #808080;
display: block;
font: bold 200% Arial, Helvetica, sans-serif;
padding: 5px;
margin: 0 0 10px;
}
.titlejgloss {
background: #91eaff;
}
.titlebgloss {
background: red;
}
Notice the comma that separates the two class selectors. This could be applied to your situation.
If that isn't adequate, then use a preprocessor of some kind to expand macros within the file. You could use PHP, for instance, on the command line to generate a CSS file from a PHP file, and upload the output.
Mike
Bookmarks