Customize radio button input without label - HTML CSS CSS Form

HTML CSS examples for CSS Form:input radio button

Description

Customize radio button input without label

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">

span.customRadio, span.customCheckbox {
   display: none;
}
input[type="radio"] {
   width: 16px;
   height: 16px;
   margin: 0;
   cursor: default;
   opacity: 0;
}
input[type="radio"] + span.customRadio {
   display: inline-block;
   width: 16px;
   height: 16px;
   background-color: white;
   margin: 0 0 0 -16px;
   border-radius: 50%;
   box-shadow: 0 0 3px -1px rgba(0, 0, 0, 0.8);
   pointer-events: none;<!--from  w w  w  .j  a  v  a  2  s  . c o m-->
}
input[type="radio"] + span.customRadio::after {
   content: '.';
   color: transparent;
   position: absolute;
   display: block;
   width: 2px;
   height: 2px;
   margin: 7px 0 0 7px;
   opacity: 0.6;
   border-radius: 50%;
   transition: .2s;
}
input[type="radio"]:checked + span.customRadio::after {
   width: 10px;
   height: 10px;
   margin: 3px 0 0 3px;
   opacity: 1;
   background-color: #3388ff;
   box-shadow: inset 0 0 2px rgba(0, 0, 0, 0.2);
}
input[type="checkbox"] {
   width: 32px;
   height: 16px;
   margin: 0;
   cursor: default;
   opacity: 0;
}
input[type="checkbox"] + span.customCheckbox {
   display: inline-block;
   width: 32px;
   height: 16px;
   background-color: white;
   margin: 0 0 0 -32px;
   border-radius: 16px;
   box-shadow: 0 0 3px -1px rgba(0, 0, 0, 0.8);
   pointer-events: none;
}
input[type="checkbox"] + span.customCheckbox::after {
   content: '.';
   color: transparent;
   position: absolute;
   display: block;
   width: 10px;
   height: 10px;
   margin: 3px 0 0 3px;
   border-radius: 16px;
   background-color: #dddddd;
   transition: .2s;
}
input[type="checkbox"]:checked + span.customCheckbox::after {
   margin: 3px 0 0 19px;
   background-color: #3388ff;
   box-shadow: inset 0 0 2px rgba(0, 0, 0, 0.2);
}


      </style> 
 </head> 
 <body> 
  <input name="test" type="radio" checked> 
  <span class="customRadio"></span> 
  <input name="test2" type="radio"> 
  <span class="customRadio"></span> 
  <br> 
  <br> In action: 
  <br> 
  <input name="test3" type="radio"> 
  <span class="customRadio"></span> 
  <input name="test3" type="radio"> 
  <span class="customRadio"></span> 
  <input name="test3" type="radio"> 
  <span class="customRadio"></span> 
  <br> 
  <br> Checkbox: 
  <br> 
  <input name="test4" type="checkbox"> 
  <span class="customCheckbox"></span>  
 </body>
</html>

Related Tutorials