How to create border to checkbox using css3 | Sanwebcorner

How to create border to checkbox using css3

Today i am going to tell you how to create custom border to checkbox using css3 and html, This one of the simple concept really used when customize the form fields.In this process we first remove the default styles for check box and then will write new css for check box and also should write the new css for disabled check box.

In this below example shows the new border to the check box and disabled checkbox, Check the demo link to view the live result of this concept, I hope this is very useful to you.

Html code for checkbox border

<!DOCTYPE html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>How to create border to checkbox using css3</title>
<link href="style.css" type="text/css" rel="stylesheet" media="screen,projection" />
<div class="section">
<h1>How to create border to checkbox using css3</h1>
<a href="" class="btn">San Web Corner</a>
<div class="container">
<div class="left">
<form action="#">
<input type="checkbox" id="test1" />
<label for="test1">Red</label>
<input type="checkbox" id="test2" checked="checked" />
<label for="test2">Yellow</label>
<input type="checkbox" id="test3" checked="checked" disabled="disabled" />
<label for="test3">Green</label>

Css code for checkbox border

/* Remove default checkbox */
[type="checkbox"]:checked {
  position: absolute;
  left: -9999px;
[type="checkbox"]:not(:checked) + label,
[type="checkbox"]:checked + label {  
  position: relative;
  overflow: hidden;
  padding-left: 35px;
  cursor: pointer;
  display: inline-block;
  height: 25px;
  line-height: 25px;

  -webkit-user-select: none; /* webkit (safari, chrome) browsers */
  -moz-user-select: none; /* mozilla browsers */
  -khtml-user-select: none; /* webkit (konqueror) browsers */
  -ms-user-select: none; /* IE10+ */

/* checkbox aspect */
[type="checkbox"] + label:before,
[type="checkbox"] + label:after {
  content: '';
  position: absolute;
  left: 0;
  z-index: 1;

  -webkit-transition: .2s;
  transition: .2s;
/* Unchecked styles */
[type="checkbox"]:not(:checked) + label:before {
  top: 0px;
  width: 19px; height: 19px;
  border: 1px solid red;
[type="checkbox"]:not(:checked) + label:after {
  top: 0px;
  width: 19px; height: 19px;
  border: 1px solid red;
  z-index: 0;
/* Checked styles */
[type="checkbox"]:checked + label:before {
  top: 2px;
  width: 6px; height: 12px;
  border-top: 1px solid transparent;
  border-left: 1px solid transparent;
  border-right: 1px solid red;
  border-bottom: 1px solid red;
  -webkit-transform: rotateZ(37deg);
  transform: rotateZ(37deg);

  -webkit-transform-origin: 20% 40%;
  transform-origin: 100% 100%;
[type="checkbox"]:checked + label:after {
  top: 0px;
  width: 19px; height: 19px;
  border: 1px solid red;
  z-index: 0;
/* disabled checkbox */
[type="checkbox"]:disabled:not(:checked) + label:before,
[type="checkbox"]:disabled:checked + label:before {
  top: 0;
  box-shadow: none;
  background-color: #444;
  width: 19px; height: 19px;
  border: 3px solid #444;
  -webkit-transform: rotateZ(0deg);
  transform: rotateZ(0deg);
[type="checkbox"]:disabled + label {
  color: #555;
[type="checkbox"]:disabled:not(:checked) + label:hover:before {
  border-color: red;

Post a comment


360 degree view product image 3d rotate 3d text 3step-form Accordion menu ajax All Browsers Animated Background Gradient animation audio controller auto complete Best accordion menu bootstrap Bootstrap form validation border bounce effect on hover Breadcrumb calculate age by dob calendar Captcha change image on mouse move color chooser countdown Counter on scroll create random number Css css animation css buttons css hover css3 customized upload Button Date picker delete data from table Different scroll speed donation form download zip email otp verification email verifier Embed eventlist Expanding Menu feedbck form flash news section close button full screen menu Google custom search Google Maps Google reCAPTCHA Google site search gradient heart animation hide menu Horizontal News ticker Hover Htm Html html dropdown html form html form validation html5 html5 form validation Iframe image hover increment decrement textbox value based on select box Javascript javascript validation Jquery jquery validation js Layered image effect on mouse hover lock & unlock page scroll marquee marquee with close button mobile number validation mobile otp login Multi-level-drop-down-menu multi-level-form multi-select-checkbox Multi-Step-form Multiple File Upload in PHP mysql News ticker on hover change text to image our team page password generator password strength checker paypal form paypal html form Photoshop PHP php mailer populate html selectbox Popup image on click the link pure css Question type form random number generate Random password Redirect page Based on the select box while submit the form responsive responsive menu responsive popup box Responsive Vertical Time line design rotate image selectbox based on select box simple coming soon page simple countdown based on end date simple typing effect slider sliding tab sms otp login statistic counter on scroll switch tag shape team member Time picker toggle toggle view transparent button underline animation up down slide validation vertical fixed sidebar Webtips whatsapp link website Whislist Youtube