gpt4 book ai didi

css - 如何删除下拉选项的下划线规则?

转载 作者:行者123 更新时间:2023-11-28 10:02:45 25 4
gpt4 key购买 nike

我有以下 DOM:

<select>
<optgroup label="a">
<option class="foo">1</option>
<option>2</option>
<option>3</option>
</optgroup>
<optgroup label="b">
<option>1</option>
<option>2</option>
<option>3</option>
</optgroup>
</select>

我想做的是给 optgroup 的标签加下划线,而不是 option 的标签。

所以我写了这个 CSS:

 optgroup {
text-align: left;
color: #222;
text-decoration: underline;
}

optgroup option {
color: red;
text-decoration: none;
}

optgroup option.foo {
color: green;
text-decoration: none;
}

我得到以下输出(来自 JSFiddle ):

enter image description here

我错过了什么来删除选项的下划线?我正在使用 Firefox 17。

最佳答案

不知道这是否适合您并且只适用于 Firefox。但我认为你的例子只适用于 firefox,所以试试这个:

    optgroup::before{
content: attr(label);
border-bottom:solid 1px #000;
width:10px;
}

fiddle

关于css - 如何删除下拉选项的下划线规则?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24614147/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com