本文介紹了Sass 和組合子選擇器的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
我剛剛發現了 Sass,對此我感到非常興奮.
I've just discovered Sass, and I've been so excited about it.
在我的網站中,我實現了一個樹狀導航菜單,使用 子組合子 (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;
}
}
}
如果你想用 >
重現相同的語法,你可以這樣做:
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
這篇關于Sass 和組合子選擇器的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!