This is the first time I find the selector and the parent selector extremely useful, so I donβt need to redefine the parents just to change the child.
Of course, this is really easy with LESS, but I have to ask!
<div id="skrollr-body" class="nonav"> <div class="skrollable"> </div> </div> #skroller-body { .skrollable { margin-top:40px; .nonav & { // this parent selector lets me modify // .skrollable without duplicating it margin-top:0px; } } }
The output of .nonav & is .nonav #skroller-body .skrollable
I am wondering if I can get #skroller-body.nonav .skrollable instead somehow without additional HTML markup (wrapper div.nonav )?
I am currently just duplicating the parent
Or to save redundant output;
#skroller-body.nonav .scrollable { margin-top:0px; }
But the whole point here is CSS code that is easy to maintain and read.
source share