0

I am having some list of checkboxes, which I tried to customize the design. But my coding doesn't works. Here is my Sample Code:

My CSS is:

input[type="checkbox"]{
display:none;
}
input[type="checkbox"] + span{
width:15px;
height:15px;
background:url(../img/uncheck_box.png) no-repeat;
display:inline-block;
}
input[type="checkbox"]:checked + span{
background:url(../img/check_box.png) no-repeat;
}

My HTML is:

<input type="checkbox" id="1" /><span></span><label for="1">AAAA</label><br />
<input type="checkbox" id="2" /><span></span><label for="2">BBBB</label><br />
<input type="checkbox" id="3" /><span></span><label for="3">CCCC</label><br />
<input type="checkbox" id="4" /><span></span><label for="4">DDDD</label><br />
<input type="checkbox" id="5" /><span></span><label for="5">EEEE</label><br />
<input type="checkbox" id="6" /><span></span><label for="6">FFFF</label>
Rajesh
  • 123
  • 2
  • 3
  • 14
  • 2
    checkboxes are tricky to customize only with CSS if you want a cross-browser solution. you should also consider a javascript alternative. – Rui Carneiro Mar 21 '13 at 11:27
  • 3
    possible duplicate of [How to style checkbox using CSS?](http://stackoverflow.com/questions/4148499/how-to-style-checkbox-using-css) – Quentin Mar 21 '13 at 11:31
  • a nice tutorial for do this http://lea.verou.me/2013/03/ios-6-switch-style-checkboxes-with-pure-css/ – Sahil Popli Mar 21 '13 at 11:31
  • Your background-image isn't visible ? Maybe you should check your image path. I don't see any error in your code. – Ben Ji Mar 21 '13 at 14:35

1 Answers1

0
<html lang="en">
<head>
<meta charset="utf-8" />
<title>jQuery UI Button - Checkboxes</title>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.2/themes/smoothness/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.2/jquery-ui.js"></script>
<link rel="stylesheet" href="/resources/demos/style.css" />
<script>
$(function() {
$( "#check" ).button();
$( "#format" ).buttonset();
});
</script>
<style>
#format { margin-top: 2em; }
</style>
</head>
<body>
<input type="checkbox" id="check" /><label for="check">Toggle</label>
<div id="format">
<input type="checkbox" id="check1" /><label for="check1">B</label>
<input type="checkbox" id="check2" /><label for="check2">I</label>
<input type="checkbox" id="check3" /><label for="check3">U</label>
</div>
</body>
</html>

I think You need This: This is best exercise.

Nisarg
  • 3,024
  • 5
  • 32
  • 54
  • you can also refer this link : http://ryanfait.com/resources/custom-checkboxes-and-radio-buttons/ – Nisarg Mar 21 '13 at 11:48