gpt4 book ai didi

css - 恢复选择元素的默认外观

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

下面是和我类似的问题: Overriding css appearance value with its default value

但是如果选择元素也有背景/边框样式,将它们覆盖为“无”或“初始”不会得到预期的结果。

例子:

HTML

<body>
<select class="select reset">
<option value="1">Option Value 1</option>
<option value="2">Option Value 2</option>
</select>
</body>

CSS

.reset {
-webkit-appearance: none;
-moz-appearance:none;
appearance:none;
background: none;
border: none;
}

.select {
-webkit-appearance: menulist;
-moz-appearance: menulist;
appearance: menulist;
background: white;
border: 2px solid #777;
}

这是没有任何样式的 select 元素的样子: enter image description here

然后在它得到“.select”类之后: enter image description here

“.select”中的样式来自第三方库,因此我无法更改它们。但是我需要在我的元素中将 select 元素的外观重置为默认值(请看第一张图片)。

这是我为此目的添加“.reset”样式时发生的情况: enter image description here

没有边框,没有背景。并且没有默认外观)

最佳答案

您想要的是the revert keyword (可能还有 the all property )将被实现。

目前情况并非如此,因此您必须删除您的 select类并避免放置 reset关于原生外观 <select> (这也更有意义)。


Styles within ".select" are coming from third-party library, so I cannot change them. But I need to reset how select element looks to its defaults in my project (look at the first picture).

看来您的元素不应该默认使用用户代理样式。

关于css - 恢复选择元素的默认外观,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47993108/

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