How to make the radio button look like this design when selected/checked?

Newsha Nik

I am trying to style the radio button so that when one is selected, it looks like this (the left/first one):

selected radio button

This is the code I have so far:

@import url(https://fonts.googleapis.com/css?family=Lato:400,300);

input[type="radio"] {
  display: none;
}
input[type="radio"]:checked + label span {
  transform: scale(1.25);
}
input[type="radio"]:checked + label .red {
  border: 2px solid #711313;
}
input[type="radio"]:checked + label .orange {
  border: 2px solid #873a08;
}
input[type="radio"]:checked + label .yellow {
  border: 2px solid #816102;
}
input[type="radio"]:checked + label .olive {
  border: 2px solid #505a0b;
}
input[type="radio"]:checked + label .green {
  border: 2px solid #0e4e1d;
}
input[type="radio"]:checked + label .teal {
  border: 2px solid #003633;
}
input[type="radio"]:checked + label .blue {
  border: 2px solid #103f62;
}
input[type="radio"]:checked + label .violet {
  border: 2px solid #321a64;
}
input[type="radio"]:checked + label .purple {
  border: 2px solid #501962;
}
input[type="radio"]:checked + label .pink {
  border: 2px solid #851554;
}

label {
  display: inline-block;
  width: 36px;
  height: 36px;
  margin-right: 10px;
  cursor: pointer;
}
label:hover span {
  transform: scale(1.25);
}
label span {
  display: block;
  width: 100%;
  height: 100%;
  transition: transform 0.2s ease-in-out;
  border-radius: 50%;
}
label span.red {
  background: #db2828;
}
label span.orange {
  background: #f2711c;
}
label span.yellow {
  background: #fbbd08;
}
label span.olive {
  background: #b5cc18;
}
label span.green {
  background: #21ba45;
}
label span.teal {
  background: #00b5ad;
}
label span.blue {
  background: #2185d0;
}
label span.violet {
  background: #6435c9;
}
label span.purple {
  background: #a333c8;
}
label span.pink {
  background: #e03997;
}
<h1>Radio Color Picker</h1>
<input type="radio" name="color" id="red" value="red" />
<label for="red"><span class="red"></span></label>

<input type="radio" name="color" id="green" />
<label for="green"><span class="green"></span></label>

<input type="radio" name="color" id="yellow" />
<label for="yellow"><span class="yellow"></span></label>

<input type="radio" name="color" id="olive" />
<label for="olive"><span class="olive"></span></label>

<input type="radio" name="color" id="orange" />
<label for="orange"><span class="orange"></span></label>

<input type="radio" name="color" id="teal" />
<label for="teal"><span class="teal"></span></label>

<input type="radio" name="color" id="blue" />
<label for="blue"><span class="blue"></span></label>

<input type="radio" name="color" id="violet" />
<label for="violet"><span class="violet"></span></label>

<input type="radio" name="color" id="purple" />
<label for="purple"><span class="purple"></span></label>

<input type="radio" name="color" id="pink" />
<label for="pink"><span class="pink"></span></label>

As you can see, in this codepen, when you select a radio button, this rule is added:

input[type="radio"]:checked + label span {
  transform: scale(1.25);
}

So the buttons will become bigger when they are selected. But I want them to keep their size and the background color covers a smaller circle than the rest. The part for adding border color is already there. How do I make this happen?

Veronika_2309

outline property might be useful here (add outline instead of border and change width and height when checked) By changing outline-offset and width, height you can adjust the amount of indentation

@import url(https://fonts.googleapis.com/css?family=Lato:400,300);

input[type="radio"] {
  display: none;
}
input[type="radio"]:checked + label span {
  /* changed */
  width: 75%;
  height: 75%;
  padding: 2px;
  margin: 2px;
  outline-offset: 4px;
}
input[type="radio"]:checked + label .red {
  outline: 2px solid #711313;/* changed */
}
input[type="radio"]:checked + label .orange {
  outline: 2px solid #873a08;/* changed */
}
input[type="radio"]:checked + label .yellow {
  outline: 2px solid #816102;/* changed */
}
input[type="radio"]:checked + label .olive {
  outline: 2px solid #505a0b;/* changed */
}
input[type="radio"]:checked + label .green {
  outline: 2px solid #0e4e1d;/* changed */
}
input[type="radio"]:checked + label .teal {
  outline: 2px solid #003633;/* changed */
}
input[type="radio"]:checked + label .blue {
  outline: 2px solid #103f62;/* changed */
}
input[type="radio"]:checked + label .violet {
  outline: 2px solid #321a64;/* changed */
}
input[type="radio"]:checked + label .purple {
  outline: 2px solid #501962;/* changed */
}
input[type="radio"]:checked + label .pink {
  outline: 2px solid #851554;/* changed */
}


label {
  display: inline-block;
  width: 36px;
  height: 36px;
  margin-right: 10px;
  cursor: pointer;
}
label:hover span {
  /*transform: scale(1.25);*/
}
label span {
  display: block;
  width: 100%;
  height: 100%;
  transition: transform 0.2s ease-in-out;
  border-radius: 50%;
}
label span.red {
  background: #db2828;
}
label span.orange {
  background: #f2711c;
}
label span.yellow {
  background: #fbbd08;
}
label span.olive {
  background: #b5cc18;
}
label span.green {
  background: #21ba45;
}
label span.teal {
  background: #00b5ad;
}
label span.blue {
  background: #2185d0;
}
label span.violet {
  background: #6435c9;
}
label span.purple {
  background: #a333c8;
}
label span.pink {
  background: #e03997;
}
<h1>Radio Color Picker</h1>
<input type="radio" name="color" id="red" value="red" />
<label for="red"><span class="red"></span></label>

<input type="radio" name="color" id="green" />
<label for="green"><span class="green"></span></label>

<input type="radio" name="color" id="yellow" />
<label for="yellow"><span class="yellow"></span></label>

<input type="radio" name="color" id="olive" />
<label for="olive"><span class="olive"></span></label>

<input type="radio" name="color" id="orange" />
<label for="orange"><span class="orange"></span></label>

<input type="radio" name="color" id="teal" />
<label for="teal"><span class="teal"></span></label>

<input type="radio" name="color" id="blue" />
<label for="blue"><span class="blue"></span></label>

<input type="radio" name="color" id="violet" />
<label for="violet"><span class="violet"></span></label>

<input type="radio" name="color" id="purple" />
<label for="purple"><span class="purple"></span></label>

<input type="radio" name="color" id="pink" />
<label for="pink"><span class="pink"></span></label>

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How do I make a Radio Widget look like a button

How to make radio "checkbox" look like a real button with ASP?

Make a radio button look like a menu item

How to make a checkbox look like a button when checkboxes are in an unordered list

How to make a radio button that is inside a table look like a buttton using bootstrap?

How to make button look like a link?

Radio Buttons stopped working when styled as button look like

How to design/make an anchor tag look the exact same like a button (very vague, but looks at the details below)

Make button look like text

How to make a RadioButton look like regular Button in JavaFX

How do I make an html link look like a button?

How do I make ReactJS button look like pressed on keyPress?

How can I change radio button to contain text and look like a selectable button?

How to make mat-checkbox like a radio button

How to make a UITableView look like this?

html/css, make a button look like a div

Make a regular button look like slack

How to make a Windows-like button design in JavaFX?

How can I preview a web app design on an iPhone and make it look like a native application?

How to make a button like this?

How i can make flat button color look same like scaffold color background

How to disguise a button to look like a checkbox

How to Style form radio button input to achieve push button look?

How to make QPlainTextEdit look like a .txt file?

How to Make Ubuntu look like Windows Vista?

How to make Java look like Windows programs?

How to make a window look like this in Java?

Flutter How to make a push() look like a pop()

How to make edittext look like a page in android