randy randy - 1 year ago 198
CSS Question

Scss - element depth recursive styles

Is there a way to make Scss check the element depth, and apply recursively added

to that element?

So say I've got this:


Then I would like to have this, but without me typing the resursion:

span {

span {

span {

I don't know the element depth and need this a lot, that's why I don't want to type this by hand. I don't know if I need a depth of 3, or a depth of up to 100.

Answer Source

Just use the direct ancestor operator >:

span > span {
    margin: 10px;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download