How can you redefine a class if its in another specific class?
div.cls { color:blue; } div.tst > div.cls { color:red; } <div class="cls">test</div> // text color = blue <div class="tst"> <div class="cls">test</div> // text color = red <div> <div class="cls">test</div> // text color = blue </div> <div>
How to make the last one also red?
http://jsfiddle.net/gpD7H/
Description. The descendant selector matches all elements that are descendants of a specified element. The first simple selector within this selector represents the ancestor element—a structurally superior element, such as a parent element, or the parent of a parent element, and so on.
The * selector selects all elements. The * selector can also select all elements inside another element (See "More Examples").
The descendant combinator — typically represented by a single space (" ") character — combines two selectors such that elements matched by the second selector are selected if they have an ancestor (parent, parent's parent, parent's parent's parent, etc.) element matching the first selector.
I used this, it work for me:
.name-of-parent * { color: red; }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With