|
Posted by Steve Pugh on 03/18/06 18:35
Bill_W_Stephens@yahoo.com wrote:
>Is there a way to simplify similar CSS class definitions. Here
>td.data_Dark and td.data_Light share common atributes that are
>different from td. See below.
>
>Is there a way to say td.data_Light is like td.data_Dark, except for
>background-color.
No, but see below.
>Also is there a way to define a color code as a variable (eg:
>myBannerColor = "C8D7E3"), so when the client wants to change the
>colour scheme, I only have to make one CSS change instead of dozens.
Not directly in CSS. But if your CSS file is created by a preprocessor
or even created on the fly with PHP or whatever then you can use that
to set variables which are transformed into static values in the
output CSS.
>td {
>background-color:red;
>border-bottom:5px solid blue;
>padding-left:1px;
>}
>
>
>td.data_Dark{
>background-color:C8D7E3;
>border-bottom:1px solid white;
>padding-left:4px;
>}
>
>
>td.data_Light{
>background-color: DBE8F9;
>border-bottom:1px solid white;
>padding-left:4px;
>}
td.data_Dark, td.data_Light {
border-bottom:1px solid white;
padding-left:4px;
}
td.data_Dark{ background-color:C8D7E3; }
td.data_Light{ background-color: DBE8F9; }
Or I'd probably do something like this (assuming that you have
alternating row colours and not some random patchwork of colours):
table.data td {
border-bottom:1px solid white;
padding-left:4px;
background-color:C8D7E3;
}
table.data tr.altrow td {
background-color: DBE8F9;
}
That way I'm only adding a handful of classes rather than one to every
cell.
BTW, consider using class names that decsribe what the elements are,
not what they look like. It stops things becoming confusing if you
later decide to swap the dark and light cells around...
Steve
--
"My theories appal you, my heresies outrage you,
I never answer letters and you don't like my tie." - The Doctor
Steve Pugh <steve@pugh.net> <http://steve.pugh.net/>
Navigation:
[Reply to this message]
|