Can someone assist me with a tricky cascading style problem that is not so straightforward?
I need to override a CSS child style with another style of equal importance (012), without changing its order in the CSS sheet...
To see a concrete example, please visit this JSfiddle link: JSfiddle Example
The requirements for the style adjustment are:
- Do not introduce a third selector (only modify the two given)
- Maintain the order of style definitions (green before red)
- Keep both selectors the same - if you change the green selector, the red selector must also change.
- The actual HTML structure is more complex than provided here (the "a" element is not just inside a div child).
For instance, if .green div a
changes to :
.green > * a
then the corresponding red selector should be:
.red > * a
The second link must have exactly the same selector (except for the color name).
EDIT: Why does it need to be done this way?
In my website, users can customize their theme colors. When viewing another user's profile, you see it in their chosen color theme but within your own theme setting. This means a green theme could be nested inside a red theme... with over 10 possible themes, it's not feasible to style every combination (green > red, red > green, blue > red, etc.).