![]() | |
![]() |
| | Thread Tools | Display Modes |
#11
| |||
| |||
|
|
On 10/05/09 02:06 pm, Ben C wrote: So I have a class .basic that does what I normally want, but I also want a .basic_red class, which is exactly the same as .basic with color:red added. Another way more in keeping with the specialization concept: .basic, .basic .red, .basic .blu { That means elements with class red that are descendents of elements that are class basic (descendents in the DOM tree, not in some putative class hierarchy we might be trying to simulate here). Not sure that's what Swifty wants. That is what he asked about. It's even in the Subject line. But yes you could do it like that, but it would mean extra divs in the markup. Every time you needed a red, you'd have to write: div class="basic"><div class="red"> rather than <div class="basic red" Then you'd just define properties for ".basic" (common stuff) and extra properties for ".basic .red" (anything red inside a basic). But I don't think there's anything to be gained by that, and having the extra divs is definitely a downside. The extra markup is definitely a bummer. But it also prevents a growth of least-specific rule sets with generic names, easing maintenance and re-use (at least of the generic names). Here I am using the specificity aspect of CSS to simulate sub-classing where a subclass adds or modifies the attributes of the parent. The other method you and Ben C outline emulates multiple inheritance |
|
which combines (possibly conflicting) rules from independent rule sets. |
|
I guess without more details about the actual application, there is no way to really decide which would be better. |
![]() |
| Thread Tools | |
| Display Modes | |
| |