Previous Message
Next Message

Basic CSS concept?

Sent by Matt Andrews on 29 October 2004 02:02


On Thu, 28 Oct 2004 21:18:12 +0100, Dave Silvester [EMAIL-REMOVED]> wrote:
> On Thursday 28 Oct 2004 19:49, Ian Skinner wrote:
> 
> > The goal here; is there a way to define common elements, colors in this
> > example, that can then be used throughout the style sheet.  Thus providing
> > one place to change the color(s) when and if that becomes necessary.
> 
> Can't do it in quite the way you suggested (unless you perhaps used something
> like PHP or ASP to generate dynamic stylesheets) but what you want to do is
> already relatively possible in a easy way, just using regular CSS classes.
> 
> The CSS:
> 
> .accent_light {
>   color: #00ff00;
> }
> 
> .accent_dark, a:hover {
>   color: #00ffdd;
> }
> 
> .contrast, a:active {
>   color: #ff00ff;
> }
> 
> div.pull {
>   background-color: #ff00ff;
> }
> 
> The HTML:
> 
> <h1 class="accent_dark">This will have whatever properties have been assigned
> to the class accent_dark</h1>
> 
> <p class="accent_dark">But so will this, because the class can be applied to
> just about anything</p>
> 
> So, this doesn't quite work with your way having predefined macros (like you
> can in C with #define and so on), but if you really wanted to do that, I'd
> suggest you look at using something server side to generate dynamic
> stylesheets.
> 
> Hope that helps!
> 
> ~Dave
> 
> --
> 
> Dave Silvester
> Music Technology Junkie
> Web: http://www.mu-sly.co.uk/
> Email: sly at mu hyphen sly dot co dot uk

nice suggestion, Dave, and i would also point out the option of using
multiple classes:

<p class="accent_dark contrast">This paragraph will get the foreground
colour from the "accent_light" class, and the background from the
"contrast" class.</p>

<h3 class="accent_light contrast higgledypiggledy">This heading will
get foreground colour from the "accent_light" class, background from
the "contrast" class, and some other styling from the
"higgledypiggledy" class.</h3>

in this way you could define your colours or colour combinations as
individual classes, and apply them to elements as you wish.

the example is not that great - it means that you have to change
markup to get different colour combinations.

but if you abstract and combine style rules, the concept of multiple
classes is very powerful and useful.
______________________________________________________________________
css-discuss [EMAIL-REMOVED]]
http://www.css-discuss.org/mailman/listinfo/css-d
List wiki/FAQ -- http://css-discuss.incutio.com/
Supported by evolt.org -- http://www.evolt.org/help_support_evolt/
Previous Message
Next Message

Message thread: