html - 是否可以更改所选单选按钮中心圆的颜色

标签 html css input webkit radio-button

是否可以设置所选单选按钮的中心圆的样式,至少在 webkit 浏览器中...?

我现在拥有的是:enter image description here

我想要的:enter image description here

我可以如下更改背景颜色、阴影等

#searchPopup input[type="radio"]{
  -webkit-appearance:none;
  box-shadow: inset 1px 1px 1px #000000;
  background:#fff;
}

#searchPopup input[type="radio"]:checked{
  -webkit-appearance:radio;
  box-shadow: none;
  background:rgb(252,252,252);
}

任何想法..?

最佳答案

您可以使用一些圆形边框技巧(呈现外圈)和伪元素 :before(呈现内圈)来模仿单选按钮,幸运的是,它可以用于输入radio 类型的字段:

input[type='radio'] {
  -webkit-appearance:none;
  width:20px;
  height:20px;
  border:1px solid darkgray;
  border-radius:50%;
  outline:none;
  box-shadow:0 0 5px 0px gray inset;
}

input[type='radio']:hover {
  box-shadow:0 0 5px 0px orange inset;
}

input[type='radio']:before {
  content:'';
  display:block;
  width:60%;
  height:60%;
  margin: 20% auto;    
  border-radius:50%;    
}
input[type='radio']:checked:before {
  background:green;
}

Working Demo.

关于html - 是否可以更改所选单选按钮中心圆的颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23167637/

相关文章:

html - Django-模板 : Tap list item and make a detail page

html - 如何在非矩形 div 中进行分词?

css - 无法单击 Bootstrap 行中的 btn-group

CSS背景背景纯色与行高的问题

c++ - 从文件中读取 uint32_t 值

javascript - 如何用js/jquery从下数到上数?

javascript - 如何访问子 Controller 中的父 Controller $scope 值

javascript - 一个简单的 .click() 在 Javascript 中不起作用

Java - 逐行读取文件直到文件末尾

c - 输入由空格分隔的 int 并将它们传递给 int 数组