Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > HTML > inherited styles

Reply
Thread Tools

inherited styles

 
 
jb
Guest
Posts: n/a
 
      03-09-2006
If there is a style that looks like this:
..border_color {border-color: #000000;}

Can another style be created which inherits border_color in its entirety?

something like...
..top_border {border-top: 1px solid; border_color: inherit}

I know color: can be inherited, but can a whole style?
 
Reply With Quote
 
 
 
 
Toby Inkster
Guest
Posts: n/a
 
      03-09-2006
jb wrote:

> Can another style be created which inherits border_color in its entirety?


Nope -- not the way you mean. CSS inheritance works differently from
object-oriented inheritance.

If you want to reuse colours and other styles over several different
classes, you might want to look into using a server-side scripting
language to serve your CSS.

e.g.

<?php
header("Content-Type: text/css");
$headingHighlight = '#ccffcc';
$normalForeground = '#006600';
?>
H1 {
border-left: 0.67em solid <?=$headingHighlight?>;
border-bottom: 2px solid <?=$headingHighlight?>;
padding: 0.25em;
}
H2 {
background: <?=$headingHighlight?>;
color: <?=$normalForeground?>;
padding: 0.25em;
}

and so on.

--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact

 
Reply With Quote
 
 
 
 
jb
Guest
Posts: n/a
 
      03-09-2006
> jb wrote:
>
>> Can another style be created which inherits border_color in its entirety?

>
> Nope -- not the way you mean. CSS inheritance works differently from
> object-oriented inheritance.
>
> If you want to reuse colours and other styles over several different
> classes, you might want to look into using a server-side scripting
> language to serve your CSS.
>
> e.g.
>
> <?php
> header("Content-Type: text/css");
> $headingHighlight = '#ccffcc';
> $normalForeground = '#006600';
> ?>
> H1 {
> border-left: 0.67em solid <?=$headingHighlight?>;
> border-bottom: 2px solid <?=$headingHighlight?>;
> padding: 0.25em;
> }
> H2 {
> background: <?=$headingHighlight?>;
> color: <?=$normalForeground?>;
> padding: 0.25em;
> }
>
> and so on.
>


It seems like a glaring omission.
 
Reply With Quote
 
Jukka K. Korpela
Guest
Posts: n/a
 
      03-12-2006
jb <> wrote:

> It seems like a glaring omission.


That's mainly because you haven't studied CSS. Try reading a good
tutorial, or even a book.

--
Yucca, http://www.cs.tut.fi/~jkorpela/
Pages about Web authoring: http://www.cs.tut.fi/~jkorpela/www.html


 
Reply With Quote
 
Toby Inkster
Guest
Posts: n/a
 
      03-12-2006
Jukka K. Korpela wrote:
> jb <> wrote:
>
>> It seems like a glaring omission.

>
> That's mainly because you haven't studied CSS.


I dunno. I think a way of defining a few constants, particularly for
colours could be handy, as sometimes certain values need to be reused, in
ways that CSS inheritance can't deal with. Something like...

@define "mainbg" "white";
@define "pale" "#efe";
@define "medium" "#9c9";
@define "dark" "#393";
@define "mainfg" "black";

BODY {
color: def("mainfg");
background: def("mainbg");
}
H1 {
color: def("dark");
background: def("mainbg");
}
H2 {
color: def("mainfg");
background: def("pale");
}
..sidepanel {
color: def("mainfg");
background: def("pale");
float: left;
width: 25%;
border: medium double def("medium");
}
..specialbox {
color: def("mainbg");
background: def("medium");
border: medium double def("dark");
}

It would make it really easy to change a site's colour scheme without
changing the rest of the styles.

--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact

 
Reply With Quote
 
Adrienne Boswell
Guest
Posts: n/a
 
      03-12-2006
Gazing into my crystal ball I observed Toby Inkster <usenet200603
@tobyinkster.co.uk> writing in news:veide3-:

> I dunno. I think a way of defining a few constants, particularly for
> colours could be handy, as sometimes certain values need to be reused, in
> ways that CSS inheritance can't deal with.


I absolutely agree with you. I'm working on a site for my church, and the
colors are following the liturgical seasons. There are five colors: white,
red, pink, purple and green, so that would be a great feature.

--
Adrienne Boswell
http://www.cavalcade-of-coding.info
Please respond to the group so others can share
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
What CSS styles are not inherited for tables in quirks mode? Kornél Pál ASP .Net 2 05-11-2009 07:19 AM
'Class.inherited' v. 'inherited' syntax inside Class 7stud -- Ruby 11 11-09-2007 06:45 PM
Column Styles Rich MCSD 0 10-02-2003 11:29 PM
Different styles in DropDownList items? Gandalf ASP .Net 3 07-17-2003 11:20 PM
Styles missing after upgrade Phil S. ASP .Net 0 07-08-2003 08:17 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57