c# - 需要在 asp 下拉列表中选择颜色

标签 c# css asp.net

我有这个下拉列表。我需要在选择后显示颜色,如果可能的话,当鼠标悬停在元素上时我需要透明选择而不是“蓝色”。

我需要这样的东西

enter image description here

 <asp:DropDownList ID="ddlTimlineStatus" runat="server" Width="50px" CssClass="DropDownListStyle">
                                                    <asp:ListItem Value="G" style="background-color:green; color:green;"></asp:ListItem> 
                                                    <asp:ListItem Value="Y" style="background-color:yellow; color:yellow;"></asp:ListItem> 
                                                    <asp:ListItem Value="R" style="background-color:red; color:red;"></asp:ListItem> 
                                                </asp:DropDownList>

此处选择了红色,但不确定为什么没有显示。 enter image description here

悬停时,您看到的蓝色实际上是红色,但在选中时显示为蓝色。 enter image description here

最佳答案

如果它是在浏览器中呈现的 select 下拉菜单,那么您可以更改 select 的 background 但您将无法更改突出显示颜色(当您悬停时) 通过使用 css! (适用于 Chrome 和其他 Webkit 浏览器)

您可能希望将 select block 更改为 ul, li 结构。

关于c# - 需要在 asp 下拉列表中选择颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42973737/

相关文章:

c# - 获取 "This method or property cannot be called on Null values"错误

c# - 在新的 C# 6 字符串语法中转义引号

c# - 连接到 Entity Framework 中的未知数据库

c# - 从异步任务触发的事件更新 MVVM 绑定(bind)

javascript - React.createElement 抛出组件未定义

asp.net - ASPX中的设计 View 无法加载

asp.net - 指定 Azure 应用服务构建的 MSBuild 版本

javascript - 外部样式表不会覆盖 Bootstrap

html - 当我点击父 div 时,我想要一个 CSS3 动画

javascript - 使用响应式设计避免移动客户端下载大图像