Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I apply a css rule to all descendants of an elements

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?

jsfiddle

http://jsfiddle.net/gpD7H/

like image 467
clarkk Avatar asked Jan 05 '12 20:01

clarkk


People also ask

How do I select all descendants in CSS?

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.

How do I apply CSS to all elements?

The * selector selects all elements. The * selector can also select all elements inside another element (See "More Examples").

How do you use descendant in CSS?

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.


1 Answers

I used this, it work for me:

.name-of-parent * { color: red; }

like image 198
TomoMiha Avatar answered Sep 30 '22 02:09

TomoMiha