views:

25

answers:

1

CSS:

.bananaTrans {
  -moz-transition : all 1s ease-in-out;
  -webkit-transition: all 1s ease-in-out;
  transition : all 1s ease-in-out;
}
.bananaClass {
  color: yellow;
}

HTML:

<div class="bananaClass">Banana Banana Banana</div>

The objective is to make every element that has class "bananaClass" inherit the properties of "bananaTrans" without editing the HTML or using JavaScript.

It ("bananaTrans") don't need exactly to be a class, it's just a bunch of properties to be used amongst other selectors.

+3  A: 

You can modify the CSS? Just add an extra .bananaClass selector

.bananaTrans, .bananaClass {
  -moz-transition : all 1s ease-in-out;
  -webkit-transition: all 1s ease-in-out;
  transition : all 1s ease-in-out;
}
.bananaClass {
  color: yellow;
}
mdma
Great. I forgot those kind of selectors. Thanks !
OrB
I was initially thinking in some way to make the bananaClass selector get the properties from bananaTrans.This in the opposite direction of what I was thinking, by making bananaTrans declaration spread over bananaClass.
OrB
I know what you mean - I've often wanted it the other way too. The only alternative there is to dynamically modify the HTML at load time (e.g. XSLT transform or similar) to add .bananaTrans to all elements currently styled with .bananaClass.
mdma