本文介紹了Sass 和組合子選擇器的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!
問題描述
我剛剛發(fā)現(xiàn)了 Sass,對此我感到非常興奮.
I've just discovered Sass, and I've been so excited about it.
在我的網(wǎng)站中,我實現(xiàn)了一個樹狀導(dǎo)航菜單,使用 子組合子 (E > F
).
In my website I implement a tree-like navigation menu, styled using the child combinator (E > F
).
有沒有辦法在 Sass 中用更簡單(或更好)的語法重寫這段代碼?
Is there any way to rewrite this code with a simpler (or better) syntax in Sass?
#foo > ul > li > ul > li > a {
color: red;
}
推薦答案
如果沒有組合子選擇器,您可能會做類似這樣的事情:
Without the combined child selector you would probably do something similar to this:
foo {
bar {
baz {
color: red;
}
}
}
如果你想用 >
重現(xiàn)相同的語法,你可以這樣做:
If you want to reproduce the same syntax with >
, you could to this:
foo {
> bar {
> baz {
color: red;
}
}
}
編譯成這樣:
foo > bar > baz {
color: red;
}
<小時>
或者在 sass 中:
Or in sass:
foo
> bar
> baz
color: red
這篇關(guān)于Sass 和組合子選擇器的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!
【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!