0

Lets start by giving an example,

Say for instance I have the class:

 <html class="browser-ie"> ... 

then on some element, I would like to call my mixin:

.browser-ie(@mixin){
        html.browser-ie {
                 @mixin();
        }
}

and be able to call it from for instance an element :

.main {
         .nested {
              .morenested {
                     .browser-ie({ min-height:100% });
              }
         }
}

and have it generate the following css:

html.browser-ie .main .nested .morenested { min-height:100%; } 

Is there anything in the toolbox that would allow for such a thing?

1

2 Answers 2

2

I think that you are looking for the parent selector in your precompiler. This should output your desired CSS.

.main {
  .nested {
    .morenested {
      html.browser-ie & {
        min-height: 100%;
      }
    }
  }
}

Keep in mind that the parent selector can fall anywhere in a declaration, and it will inherit all of the classes you have nested into up to that point, and append them to your string.

Sign up to request clarification or add additional context in comments.

6 Comments

I actually beat you too it by 1 second :P Good job. Thanks man! I have to wait 7 more minutes
However, I must say I am a bit dissapointed it doesn't work with mixins. I can't pass the code block to the mixin.
This doesn't work, but is there something that might? hastebin.com/ucivisinan.avrasm
I am not sure what you mean by "keep in mind". Isn't that what I am asking for? Are you talking about certain edge cases which might break things?
I turned the remaining discussion into a new question: stackoverflow.com/questions/32278206/…
|
0

do you mean something like this?

.myColor{
    min-height:100%;
}


    .main{
        .nested{
            .morenested{
                .myColor;
            }
        }
    }

result:

/* Generated by less 2.4.0 */
.myColor {
  min-height: 100%;
}
.main .nested .morenested {
  min-height: 100%;
}

1 Comment

Yes, like that. Only I don't want my rule to be defined under html.browser-ie. I can't have code living in separate places for each browser, impossible to maintain. There is another answer to this question below.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.