![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Can I define a class so that it inherits most of its content from another class? 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. This way, when I change the .basic class then the .basic_red class follows suit. |
#3
| |||
| |||
|
|
This way, when I change the .basic class then the .basic_red class follows suit. No, but you can do it like this: .basic { ... } .red { ... } .blue { ... } div class="basic red">... div class="basic blue">... |
#4
| |||
| |||
|
|
div class="basic red">... div class="basic blue">... |
#5
| |||
| |||
|
|
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. No, but you can do it like this: .basic { ... } .red { ... } .blue { ... } Another way more in keeping with the specialization concept: |
#6
| |||
| |||
|
|
Another way more in keeping with the specialization concept: .basic, .basic .red, .basic .blu { ... all the stuff just for .basic ... }; .basic .red { ... just for .red ... } .basic .blu { ... just for .blu ... } |
#7
| |||
| |||
|
|
On 10/05/09 12:22 am, 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. No, but you can do it like this: .basic { ... } .red { ... } .blue { ... } Another way more in keeping with the specialization concept: .basic, .basic .red, .basic .blu { ... all the stuff just for .basic ... }; |
|
.basic .red { ... just for .red ... } .basic .blu { ... just for .blu ... } |
#8
| |||
| |||
|
|
On 10/05/09 12:22 am, 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. No, but you can do it like this: .basic { ... } .red { ... } .blue { ... } Another way more in keeping with the specialization concept: .basic, .basic .red, .basic .blu { |
|
... all the stuff just for .basic ... }; .basic .red { ... just for .red ... } .basic .blu { ... just for .blu ... } |
#9
| |||
| |||
|
|
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 |
#10
| |||
| |||
|
|
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. |
![]() |
| Thread Tools | |
| Display Modes | |
| |