简体   繁体   English

如何更改asp:DropDownList扩展的背景色? CSS类

[英]How to change asp:DropDownList extended background color ? CSS class

Here the class and the example 这里是班级和例子

    <asp:DropDownList ID="dropDownListZenithYesNo" 
    CssClass="dropDownBox" runat="server"></asp:DropDownList>

And here the CSS class of that dropdownlist 这是该下拉列表的CSS类

.dropDownBox
{
    font-size: 13px;
    color: #3b3b3b;
    padding: 5px;
    background: -moz-linear-gradient(
    top,
    #f0f0f0 0%,
    #d6d6d6);
    background: -webkit-gradient(
    linear, left top, left bottom, 
    from(#f0f0f0),
    to(#d6d6d6));
    -moz-border-radius: 3px;
    -webkit-border-radius: 3px;
    border-radius: 3px;
    border: 1px solid #999999;
    -moz-box-shadow: 0px 1px 2px rgba(000,000,000,0.5), inset 0px 1px 0px rgba(255,255,255,1);
    -webkit-box-shadow: 0px 1px 2px rgba(000,000,000,0.5), inset 0px 1px 0px rgba(255,255,255,1); 
    box-shadow: 0px 1px 2px rgba(000,000,000,0.5), inset 0px 1px 0px rgba(255,255,255,1);
     text-shadow: 0px 1px 0px rgba(255,255,255,1), 0px 1px 0px rgba(255,255,255,0);
}

And here how it looks nice when you not click to see elements 在这里,当您不单击查看元素时它看起来很好

在此处输入图片说明

And this is how very bad it looks when you click to see elements 这就是您单击以查看元素时看起来非常糟糕

在此处输入图片说明

Testing with windows 7 firefox latest version 使用Windows 7 Firefox最新版本进行测试

CSS CSS3 HTML dropdown list color style CSS CSS3 HTML下拉列表颜色样式

Add the following css below your css 在您的CSS下方添加以下CSS

.dropDownBox option
    {
        font-size: 13px;
        color: #3b3b3b;
        padding: 5px;
        background: -moz-linear-gradient(
top,
#f0f0f0 0%,
#d6d6d6);
        background: -webkit-gradient(
linear, left top, left bottom, 
from(#f0f0f0),
to(#d6d6d6));
        -moz-border-radius: 3px;
        -webkit-border-radius: 3px;
        border-radius: 3px;
        border: 1px solid #999999;
        -moz-box-shadow: 0px 1px 2px rgba(000,000,000,0.5), inset 0px 1px 0px rgba(255,255,255,1);
        -webkit-box-shadow: 0px 1px 2px rgba(000,000,000,0.5), inset 0px 1px 0px rgba(255,255,255,1);
        box-shadow: 0px 1px 2px rgba(000,000,000,0.5), inset 0px 1px 0px rgba(255,255,255,1);
        text-shadow: 0px 1px 0px rgba(255,255,255,1), 0px 1px 0px rgba(255,255,255,0);
    }

But test your page in multiple browsers because it may have different results. 但是,在多个浏览器中测试您的页面可能会导致不同的结果。 Infact i have different results. 实际上我有不同的结果。

You must be inheriting from a default style. 您必须从默认样式继承。 I would suggest specifying the color for your options: 我建议为您的选项指定颜色:

.dropDownBox option{
    font-size:1.2em;
    background-color:#FF0 !important;
    display:block;
}

Here is the fiddle 这是小提琴

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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