開始選擇I類要選擇不含一類具有z-depth-
開頭的子元素:不以字符串
<div class="well">
<div class="well"></div>
</div>
因此,如果內。好了還含有一類像z-depth-1
它將不會被選中。
這是不工作,因爲內部。好總是選擇:
.well .well:not([class^="z-depth-"])
是,即使可能嗎?
開始選擇I類要選擇不含一類具有z-depth-
開頭的子元素:不以字符串
<div class="well">
<div class="well"></div>
</div>
因此,如果內。好了還含有一類像z-depth-1
它將不會被選中。
這是不工作,因爲內部。好總是選擇:
.well .well:not([class^="z-depth-"])
是,即使可能嗎?
您不能選擇不包含與z-depth-
開始CSS,你只能一類的子元素:
class
屬性值.well .well:not([class^="z-depth-"]) {
color: red;
}
<div class="well z-depth-1">Parent div
<div class="z-depth-2 well">First child div</div>
<div class="well z-depth-3">Second child div</div>
</div>
z-depth-
子開始
class
屬性的值不包含z-depth-
子:.well .well:not([class*="z-depth-"]) {
color: red;
}
<div class="well z-depth-1">Parent div
<div class="z-depth-2 well">First child div</div>
<div class="well z-depth-3">Second child div</div>
<div class="well">Third child div</div>
</div>
你也可以詳細瞭解MDN上的所有CSS選擇器。
您將需要結合^=
和*=
以獲得所需的結果。
.well:not([class^="z-depth-"]) { /*will ignore elements if the first class is z-depth-* */
background-color: lightgreen;
}
.well:not([class*=" z-depth-"]) { /*will ignore elements if z-depth-* is second class or later */
background-color: skyblue;
}
<div class="z-depth-1 well">z-depth-1 well</div>
<div class="well z-depth-1">well z-depth-1</div>
下面是關於如何使用屬性選擇一個nice guide。
你的答案和選定的答案一起幫助我指出了正確的方向。這確實是我對「^」符號的理解。 '.well .well:not([class * =「z-depth - 」])'工作。也謝謝你。 – rzb
'.well:not([class^=「z-depth - 」])'如果第一類是'z-depth- *' – pol
「這不起作用」並不是一個真正的問題聲明。向我們展示一個演示問題的例子會更好,而不是讓回答者(如下面的謝爾蓋)彌補您可能面臨的問題。 –
「不工作」是問題的「你有什麼嘗試」部分。前面的句子已經說明了這個問題。 – rzb