input:required{
background-color:#f00;
}
input:required label{
color: #FF3434;
}
我的表单目前有上面的 CSS 代码,
我希望能够在需要该字段时将标签设为红色。我的输入字段是:
<label for="frmComTelephone">Telephone</label>
<input type="number" name="Telephone" id="frmComTelephone"/>
<label for="frmIn1IncinTime">Time</label>
<input type="text" name="Incident Time" id="frmIn1IncinTime" required="required"/><br>
但是那个 CSS 不起作用我该如何解决这个问题?
第二个问题是我有以下 CSS:
input:focus
{
background-color:yellow;
}
input[type="text"], input[type="date"],input[type="time"],input[type="number"],textarea,select
{
border-radius:5px;
border-width: 1px;
border-style: solid;
border-color: #C6C6C6;
height:41px;
background-color: #FF3434;
width: 100%;
}
但是当项目被聚焦时它不会变成黄色,如果我删除“背景颜色:#FF3434;” 对焦变黄了?
我正在做的事不能做吗?还是我要解决这个问题?
谢谢