Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to change the color of selected radio button's center circle

Is it possible to style the center circle of a selected radio button, at least in webkit browsers…?

What I have now: enter image description here

What I want: enter image description here

I can change the background color, shadow etc as follows

#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);
}

Any ideas..?

like image 226
T J Avatar asked Apr 19 '14 08:04

T J


1 Answers

You can mimic the radio button using some round border trick (to render the outer circle) and the pseudo-element :before (to render the inner circle) which can fortunately be used on an input field of radio type:

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.

like image 69
King King Avatar answered Oct 12 '22 03:10

King King