当我访问许多网页时,我注意到标准单选按钮在选择时是蓝色的,如下所示:
据我所知,没有 CSS 将单选按钮的外观更改为蓝色。然而,当我制作一个非常标准的 html 页面时,它看起来像这样:
我到底错过了什么?是否是外部库导致按钮显示蓝色?
这是标准单选按钮代码:
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
</head>
<body>
<input type="radio" name="color"> Grey
</body>
</html>
我正在使用 chrome 版本 65 来检查
最佳答案
这些元素的样式主要由操作系统/浏览器控制,并且覆盖并非在所有浏览器中通用。来自 MDN :
By default, radio buttons (and checkboxes) are styled with the operating system's native styles for those controls. By specifying
appearance: none
, you can remove the native styling altogether, and create your own styles for them.
本文的其余部分提供了如何使用 appearance: none
CSS 规则设置单选元素样式的示例。
关于html - 是什么让单选按钮变成蓝色和灰色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50029518/