问题
I have a CSS like this:
.button-navigation-container button {
/*some properties*/
}
.button-navigation-container button.back-button,
.button-navigation-container button.cancel-button {
text-align: right;
padding-right: 2%;
}
But now I want to convert to LESS but I'm not sure which kind of selector should I use to get the back-button
and cancel-button
with the same style. Something like this:
.button-navigation-container button {
/*some properties*/
/*Selector for cancel-button and back-button ?*/{
text-align: right;
padding-right: 2%;
}
}
Should I use extend()?
回答1:
Less
.button-navigation-container {
button {
/*some properties for button*/
&.back-button, &.cancel-button {
text-align: right;
padding-right: 2%;
}
}
}
StyleSheet (Generated from the LESS)
.button-navigation-container button {
/*some properties for button*/
}
.button-navigation-container button.back-button,
.button-navigation-container button.cancel-button {
text-align: right;
padding-right: 2%;
}
来源:https://stackoverflow.com/questions/23181607/convert-css-to-less-selector