如何对所有下拉列表应用焦点 css



>我的所有文本框都有以下类

textarea:focus,input[type="text"]:focus,input[type="password"]:focus
{
border-color:#BBBBBB;
box-shadow: inset 0 0 2px #888;
border-color:#3C8CDD;
color: #063E61;
color: rgb(171, 171, 171);
color:#063E61;
border-color: #3C8CDD;
font-family:Verdana;
font-size: 10px;
font-size:normal;
}

我可以对类型下拉列表使用相同的 css 类吗?

 <asp:DropDownList ID="EnqDDL" runat="server" TabIndex="1" AutoPostBack="true" CssClass="dropdown" OnSelectedIndexChanged="EnqDDL_SelectedIndexChanged" ValidationGroup="Save_Group">
                                                        </asp:DropDownList>
asp:DropDownList

HTML中呈现为select

因此,若要在所有下拉列表中实现焦点 CSS,请将以下内容添加到 CSS 规则中:

select:focus{}

所以你的代码变成这样:

textarea:focus,input[type="text"]:focus,input[type="password"]:focus,select:focus
{
    border-color:#BBBBBB;
    box-shadow: inset 0 0 2px #888;
    border-color:#3C8CDD;
    color: #063E61;
    color: rgb(171, 171, 171);
    color:#063E61;
    border-color: #3C8CDD;
    font-family:Verdana;
    font-size: 10px;
    font-size:normal;
}
​select:focus {
    background-color:red;
}​

将用于下拉列表。

http://jsfiddle.net/c8wjL/

最新更新