我想爲輸入元素應用一些css,我只想爲那些未禁用且未提交的輸入,下面的CSS不起作用,也許如果有人可以解釋我如何添加。Css僞類輸入:不是(禁用)不是:[type =「submit」]:focus
input:not(disabled)not:[type="submit"]:focus{
box-shadow:0 0 2px 0 #0066FF;
-webkit-box-shadow:0 0 4px 0 #66A3FF;
}
我想爲輸入元素應用一些css,我只想爲那些未禁用且未提交的輸入,下面的CSS不起作用,也許如果有人可以解釋我如何添加。Css僞類輸入:不是(禁用)不是:[type =「submit」]:focus
input:not(disabled)not:[type="submit"]:focus{
box-shadow:0 0 2px 0 #0066FF;
-webkit-box-shadow:0 0 4px 0 #66A3FF;
}
相反的:
input:not(disabled)not:[type="submit"]:focus {}
用途:
input:not([disabled]):not([type="submit"]):focus {}
disabled
是一個屬性,因此所需要的支架,你似乎混淆了在/缺少冒號和括號:not()
選擇器。
有一點要注意:我可能是錯的,但我不認爲disabled
投入通常可以獲得焦點,所以這部分可能是多餘的。
您在選擇中有幾個拼寫錯誤。應該是:input:not([disabled]):not([type="submit"]):focus
請參見此jsFiddle以獲得概念驗證。在旁註中,如果我刪除了「background-color」屬性,那麼box陰影不再起作用。不知道爲什麼。
你的語法很棘手。
更改此:
input:not(disabled)not:[type="submit"]:focus{
到:
input:not(:disabled):not([type="submit"]):focus{
似乎很多人都沒有意識到:enabled
和:disabled
是有效的CSS選擇器...
爲什麼不縮短到'input:enabled:not([type =「submit」]):focus {'? – 2017-10-11 21:18:25
@SeantheBean好點。這更乾淨。 – Gavin 2017-10-12 15:36:17
是的,我只讀屬性在我的項目:)謝謝! – BurebistaRuler 2012-02-09 08:23:11
:不([disabled])是一種非常詳細的寫作方式:enabled https://developer.mozilla.org/en-US/docs/Web/CSS/:enabled – Adria 2014-10-30 04:14:06
readonly怎麼樣? – Cullub 2016-01-23 18:54:27