1
下面的代碼:我怎樣纔能有多個選擇器混合?
.positionBase (@name,@size: 16px,@position: 0) {
[disabled] [email protected]{name}, .disabled [email protected]{name}, [email protected]{name} {
background-position: @position*@size [email protected];
}
[email protected]{name} {
background-position: @position*@size 0;
}
[email protected]{name}.dark {
background-position: @position*@size -2*@size;
}
[email protected]{name}.dark:hover, a:hover [email protected]{name}.dark, button:hover [email protected]{name}.dark, .button:hover [email protected]{name}.dark, .interactable:hover [email protected]{name}.dark {
background-position: @position*@size -3*@size;
}
}
* {
.positionBase(testing,16px,0)
}
產生如我所期望的:
* [disabled] .icon.testing,
* .disabled .icon.testing,
* .disabled.icon.testing {
background-position: 0px -16px;
}
* .icon.testing {
background-position: 0px 0;
}
* .icon.testing.dark {
background-position: 0px -32px;
}
* .icon.testing.dark:hover,
* a:hover .icon.testing.dark,
* button:hover .icon.testing.dark,
* .button:hover .icon.testing.dark,
* .interactable:hover .icon.testing.dark {
background-position: 0px -48px;
}
如何擺脫*
前綴,只是有選擇不帶前綴?
東西不起作用:
.positionBase(testing,16px,0)
* {
.positionBase(testing,16px,0)
}
和
{
.positionBase(testing,16px,0)
}
我的谷歌foo是弱,我發現沒有什麼會讓我認爲這是可能的,在這種情況下,我想使用*
前綴,但這對性能也非常不利。有任何想法嗎?
感謝
黨吧!只要SO讓我接受這一點,我會......謝謝 – Nate
所以顯然你不需要在EVERY線後的半色,只是在支架集中的線或獨立線......道德:總是使用分號。 – Nate
*總是使用分號*是遵循非常好的生活格言 –