Less 在类中重新应用默认元素属性

Less 在类中重新应用默认元素属性,less,Less,LESS使重用一个类中的属性或另一个类中的ID规则集变得容易。有没有办法在另一个规则集中引用元素(没有类或ID)的属性?我想做一些类似的事情: // Defined in a base .less file somewhere a { color: blue; } // Defined within a more specific file .myClass a { color: red; } // #myElement is used within .myClass, bu

LESS使重用一个类中的属性或另一个类中的ID规则集变得容易。有没有办法在另一个规则集中引用元素(没有类或ID)的属性?我想做一些类似的事情:

// Defined in a base .less file somewhere
a {
    color: blue;
}

// Defined within a more specific file
.myClass a {
    color: red;
}

// #myElement is used within .myClass, but I'd like to re-use the
// base styles.
#myElement a {
    a();
}
您可以使用
*:extend()
伪类:

#myElement a {
    background: green;
    &:extend(a);
}
见: