2017-06-14 30 views
3

我試圖創建一個CSS規則來改變輸入的背景顏色,如果它是必需的,但機器人禁用或聚焦CSS輸入不集中或禁用

我有這個,但它不工作明顯!

<input type="tel" class="form-control" placeholder="Phone" name="phone" value="" required> 

和css:

input:not(disabled):not(focus):required { 
    background-color: rgba(255,0,0,.10) 
} 
+0

你有什麼工作對我蠻好,https://開頭的jsfiddle。 net/bomnrm0d/ –

回答

5

使用:您的僞選擇:disabled:focus

input:required:not(:disabled):not(:focus) 
+1

是的那個票! –

+0

@Roko請添加一些解釋..是它的順序嗎? – tech2017

+0

@tech對不起,我是手機,正在尋找'字符:)沒有。訂單不重要,但缺少':' –