I have no experience with checkbox styling. Is there anyway to achieve border radius effect on checkboxes? How can I style checkbox like this image?
Asked
Active
Viewed 1.9k times
2
-
1http://www.hongkiat.com/blog/css3-checkbox-radio/ – Bram Vanroy Sep 24 '13 at 04:45
-
Googled your exact title and got several good alternatives. Such as http://csscheckbox.com/ – Itay Sep 24 '13 at 04:45
-
1http://stackoverflow.com/questions/4148499/how-to-style-checkbox-using-css – The Alpha Sep 24 '13 at 04:47
-
Associate a label to every checkboxe, hide the checkbox part and style the label as you want. See this answer: http://stackoverflow.com/questions/18879084/making-a-div-like-radio-button/18879818#18879818 – service-paradis Sep 24 '13 at 20:21
2 Answers
8
HTML
<div class="checkbox">
<input id="check1" type="checkbox" name="check" value="check1">
<label for="check1">Checkbox No. 1</label>
<br>
<input id="check2" type="checkbox" name="check" value="check2">
<label for="check2">Checkbox No. 2</label>
</div>
CSS
label {
display: inline-block;
cursor: pointer;
position: relative;
padding-left: 25px;
margin-right: 15px;
font-size: 13px;
margin-bottom: 10px;
}
label:before {
content:"";
display: inline-block;
width: 16px;
height: 16px;
margin-right: 10px;
position: absolute;
left: 0;
bottom: 1px;
background-color: #aaa;
box-shadow: inset 0px 2px 3px 0px rgba(0, 0, 0, .3), 0px 1px 0px 0px rgba(255, 255, 255, .8);
border-radius: 3px;
}
input[type=checkbox] {
display: none;
}
input[type=checkbox]:checked + label:before {
content:"\2713";
text-shadow: 1px 1px 1px rgba(0, 0, 0, .2);
font-size: 15px;
color: #f3f3f3;
text-align: center;
line-height: 15px;
}
As seen here.
What it should look like in modern browsers.

Bram Vanroy
- 27,032
- 24
- 137
- 239
-
http://jsfiddle.net/vGja8/ is the code that you posted. it doesn't give any result similiar to image I posted – heron Sep 24 '13 at 04:50
-
@heron It does. See my added fiddle. I didn't post all the needed CSS thoughn but I added some more. – Bram Vanroy Sep 24 '13 at 04:52
-
Neither past answer nor updated doesn't give anything visually similiar to image I posted. Re-read my question please – heron Sep 24 '13 at 04:54
-
@heron You wanted to style your checkboxes, and add border radius? Well, my code does that. Unless you are looking at the fiddle in an old browser. see my added screenshot. – Bram Vanroy Sep 24 '13 at 05:18
-
-
2@heron this gets you very close. You have not shown any efort at solving this yourself. This is a good answer and if you know anything about CSS two or three changes to the CSS will give you exactly what you need. The more effort you put in the more effort we will put in. Don't expect to get something for nothing. – Jon P Sep 24 '13 at 05:28
-
-
@Dannyboy They sure are clickable, so I presume they can be used on touch devices as well. It's pure CSS, so it should work I think. – Bram Vanroy Jan 22 '14 at 17:35
2
<div class="square">
<input type="checkbox" value="None" id="square" name="check" />
<label for="square"></label></div>
css3 code:
.square label {
cursor: pointer;
position: absolute;
width: 20px;
height: 20px;
left: 4px;
top: 4px;
-webkit-box-shadow: inset 0px 1px 1px white, 0px 1px 0px white;
border:1px solid lightblue;
background: -webkit-linear-gradient(top, white 0%, white 100%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#222', endColorstr='#45484d',GradientType=0 ); }
.square label:after {
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";
filter: alpha(opacity=0);
opacity: 0;
content: '';
position: absolute;
width: 9px;
height: 5px;
background: transparent;
top: 4px;
left: 4px;
border: 3px solid blue;
border-top: none;
border-right: none;
-webkit-transform: rotate(-45deg);
-moz-transform: rotate(-45deg);
-o-transform: rotate(-45deg);
-ms-transform: rotate(-45deg);
transform: rotate(-45deg); }
.square input[type=checkbox]:checked + label:after {
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";
filter: alpha(opacity=100);
opacity: 1; }
i am modifying css code...check it

proxyserver
- 53
- 8
-
here is the code that you posted http://jsfiddle.net/6zbX4/1/ . http://screencast.com/t/FDbB2WJy5L4f why right side border looks like that? – heron Sep 24 '13 at 05:10
-
ya. you change background-color to white.border color to light blue. – proxyserver Sep 24 '13 at 05:23
-
heron check this modified code. and add this property border-radius:2px; in square label class. ok – proxyserver Sep 24 '13 at 05:32