3

This might be difficult to explain. Is there a way to have less not write out the @child argument without overloading the mix-in? I really don't want two mix-ins. If I use "" double quotes are outputted. I would like the LESS compiler to leave it blank.

LESS CODE

.build-on(size, @child) 
{
    &--1-1 @{child}
    {             
        width: 100%;
    }

    &--1-2 @{child}
    {
        width: 50.0%;
    }

    &--1-3 @{child}
    {
        width: 33.3%;
    }

    &--1-4 @{child}
    {
        width: 25.0%;
    }

    &--1-5 @{child}
    {
        width: 20.0%;
    }
}

// I might need to provide a child element

.data-table
{
    .build-on(size, table);
}

// I might not

.grid
{
    .build-on(size, "");
}
4

1 回答 1

3

像这样传递它:

.yourClass
{
    .build-on(size, ~'');
}

或者更好……

定义一个默认值:.build-on(size, @child: ~'') { ... }那么不需要第二个:

.yourClass
{
    .build-on(size);
}
于 2013-02-14T13:03:48.417 回答