如何更改单选按钮悬停颜色
我使用这个 css 代码作为文本区域的悬停颜色并输入它在除 IE 之外的所有浏览器中正常工作,其显示如下图所示。如何将单选按钮背景仅设置为透明。
我的 css 代码:
input:focus, input:hover, textarea:focus, textarea:hover {
border: 0 none;
background: blue;
}
i am using this css code for hover color for the text area and inputs it works fine in all browsers except IE its show like the image below. How to set the radio button background only to transparent.
my css code:
input:focus, input:hover, textarea:focus, textarea:hover {
border: 0 none;
background: blue;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
由于您直接设置
input
样式,因此单选按钮和复选框也将成为目标。避免这种情况的一个简单方法是使用:not()
选择器,如下所示:input:not([type=radio]):not([type=checkbox]):not( [type=submit]):not([type=image]):not([type=button]):focus
。请注意,这在 IE<8(?) 中不起作用。Since you're styling
input
directly, radiobuttons and checkboxes will also be targeted. An easy way to avoid that is to use the:not()
selector like so:input:not([type=radio]):not([type=checkbox]):not([type=submit]):not([type=image]):not([type=button]):focus
. Note that this doesn't work in IE<8(?) though.powerbuoy 的说法是正确的,除了正常的文本框之外,输入选择器还选择复选框和收音机。
但我有一个建议,您可以使用它来代替他的,它可以在更多浏览器中使用。
基本上,您可以向所有复选框和单选按钮输入添加一个类。
所以你的复选框和单选按钮 html 就变成了
,然后添加 css 来重置复选框和单选按钮的样式
powerbuoy is right about that the input selector select checkboxes and radios in addition to the normal text boxes.
but i have a suggestion that you can use instead of his that will work in more browsers.
basically you can add a class to all your checkbox and radio buttons inputs.
so your checkbox and radio html becomes
and then add the css to reset the style for the checkboxes and radios like that