Style radio buttons - HTML CSS CSS Form

HTML CSS examples for CSS Form:input radio button

Description

Style radio buttons

Demo Code

ResultView the demo in separate window

<html>
 <head> 
  <meta name="viewport" content="width=device-width, initial-scale=1"> 
  <style id="compiled-css" type="text/css">

.radio {<!--  w  ww .j  a  v a 2s  .c  o  m-->
   border: 0;
   clip: rect(0 0 0 0);
   height: 1px;
   margin: -1px;
   overflow: hidden;
   padding: 0;
   position: absolute;
   width: 1px;
}
.radio + label {
   padding-left: 23px;
   cursor: pointer;
   position: relative;
   display: inline-block;
   line-height: 24px;
   margin: 8px 0;
}

.radio + label:before {
   content: " ";
   position: absolute;
   left: 0;
   top: 50%;
   -webkit-border-radius: 16px;
   -moz-border-radius: 16px;
   border-radius: 16px;
   -webkit-box-sizing: border-box;
   -moz-box-sizing: border-box;
   box-sizing: border-box;
   -webkit-transition(background 250ms ease-in-out);
   -moz-transition(background 250ms ease-in-out);
   -o-transition(background 250ms ease-in-out);
   transition(background 250ms ease-in-out);

   width: 10px;
   height: 10px;
   margin-top: -5px;
   background: #f97e76;
}
.radio:checked + label:before {
   background: #a8bd44;
}


      </style> 
 </head> 
 <body> 
  <input type="radio" class="radio" name="radio" id="radio-1"> 
  <label for="radio-1">Option One</label> 
  <br> 
  <input type="radio" class="radio" name="radio" id="radio-2"> 
  <label for="radio-2">Option Two</label> 
  <br>  
 </body>
</html>

Related Tutorials