2

For example I have next less code

form.someForm
{
    .form-group
    {
        > div
        {
            @media @wideMobile
            {
                width: calc(~"100%-144px");            
            }
        }

        > label
        {
            @media @wideMobile
            {
                width: 138px;            
            }
        }

    }
}  

I want to write something like

form.someForm
{
    .setWidths(138px,144px); 
}

To get the same result. How can I do that?

Harry
  • 87,580
  • 25
  • 202
  • 214
user1325696
  • 616
  • 1
  • 8
  • 16

1 Answers1

7

I guess all those examples at the docs could emanate a few ideas:

form.someForm {
    .setWidths(138px, 144px);
}

// the mixin:

.setWidths(@labelWidth, @divMargin) {
    .form-group {
        > div {
            @media @wideMobile {
                width: calc(100% ~'-' @divMargin);
            }
        }

        > label {
            @media @wideMobile {
                width: @labelWidth;
            }
        }
    }
}

Or even shorter (if the descendants share same media query):

.setWidths(@labelWidth, @divMargin) {
    .form-group {
        @media @wideMobile {
            > div   {width: calc(100% ~'-' @divMargin)}
            > label {width: @labelWidth}
        }
    }
}
seven-phases-max
  • 11,765
  • 1
  • 45
  • 57
  • Sorry for the delay. Could not have a chance to try. This is really working thank you very much. This is so nice to hide the knowledge of how it is structured. – user1325696 Jun 06 '14 at 21:12