2017-06-14 46 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对不起,我是手机,正在寻找'字符:)没有。订单不重要,但缺少':' –