简体   繁体   中英

How to apply focus css for all drop downs?

I have below class for all textboxes

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;
}

Can i use this same css class for type dropdowns?

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

an asp:DropDownList is rendered as a select in HTML.

So, to implement the focus CSS on all drop-downs, add the following to your CSS rules:

select:focus{}

So your code becomes like so:

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;
}​

will be used for dropdown lists.

Example http://jsfiddle.net/c8wjL/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM