format checkbox input

I have a list of checkboxes that works fine. The label text can be handeled by a style

I just cant set a background or any properties of the checkbox

<form method="post" name="forma" action="modex.php" >


<div style="height: 6em; width: 12em; overflow: auto;">
	
		

<input  type="checkbox" id="armadora" name="armadora[]" value="AUDI"  onclick="changeFunc('AUDI');">
<label style="background-color: #EAF5FE; font-family:Arial;" for="AUDI">AUDI</label>
<br>

<input  type="checkbox" id="armadora" name="armadora[]" value="BENTLEY"  onclick="changeFunc('BENTLEY');">
<label style="background-color: #EAF5FE; font-family:Arial;" for="BENTLEY">BENTLEY</label>
<br>

<input  type="checkbox" id="armadora" name="armadora[]" value="BMW"  onclick="changeFunc('BMW');">
<label style="background-color: #EAF5FE; font-family:Arial;" for="BMW">BMW</label>
<br>
 
</div>
<input type="submit">
</form>

Open in new window

robrodpAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

GaryCommented:
Not really possible, the checkbox is one of those elements that cannot be styled - you have to replace it with a different element and bind the two together

If you are using jQuery there's a rake of plugins you can use
http://www.sitepoint.com/15-jquery-radio-button-checkbox-style-plugins/
0
robrodpAuthor Commented:
Mh... well I changed to checkboxes because jquery is not working with ie 11 And as yoy commented, I thought I could format it anyway I needed. I guess I got theat wrong
0
GaryCommented:
jquery is not working with ie 11
Uh?
Would be easier to just use a list tag.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

robrodpAuthor Commented:
Definitely a list tag is the way to go

Thx
}
0
Kyle HamiltonData ScientistCommented:
if you are not concerned with IE 8 or below, you can use the :checked pseudo class to "style" the check boxes. Essentially, you will be hiding the checkbox and replacing it with an image. By styling the label element all the functionality of the checkbox will remain intact.

In this example, I am using modernizr to test for support of the :checked pseudo class. This is optional. But remember to remove the ".csschecked" qualifier if you remove the modernizr code. And of course, provide your own check graphic.

You do not need jquery for this one, but like Gary pointed out, why your jquery isn't working in IE 11 is questionable.

<!doctype html>
<html>
	<head>
		<meta charset="UTF-8">
        <title></title>

        <meta name="viewport" content="width=device-width, initial-scale=1" /> 
        <meta name="apple-mobile-web-app-capable" content="yes" /> 
        <meta name="apple-mobile-web-app-status-bar-style" content="black" /> 
        <link rel="apple-touch-startup-image" href="/startup.png">

        <meta name="description" content="Graphic design and web development">
        <meta name="author" content="C &amp; P Generation, LLC">
		<style>
			*{
				-webkit-box-sizing:border-box;
				-moz-box-sizing:border-box;
				box-sizing:border-box;
				margin:0;
				padding:0;
			}
			.csschecked .single-checkbox{
			    position:relative;
			    min-height:22px;
			}

			.csschecked .single-checkbox input{
			    position:absolute;
			    opacity:0;
			    filter: alpha(opacity = 0);
			}
			.csschecked .single-checkbox label{
			    position:absolute;
			    cursor:pointer;
			    padding-left:20px;
			    padding-top: 2px;
			    background:url(http://candpgeneration.com/toys/images/checkbox.png) 0 0 no-repeat;
			}
			.csschecked .single-checkbox :checked + label{
			    background-position:0 -30px;
			}

		</style>
		<script src="http://modernizr.com/downloads/modernizr-latest.js"></script>
		<script>
		Modernizr.addTest('csschecked', function () {
				  return Modernizr.testStyles("#modernizr input {margin-left:0px;} #modernizr input:checked {margin-left: 20px;}", function (elem) {
				    var chx = document.createElement('input');
				    chx.type = "checkbox";
				    chx.checked = "checked";
				    elem.appendChild(chx);
				    return elem.lastChild.offsetLeft >= 20;
				  });
				});
		</script>
	</head>
	<body>
		<div class="wrapper">
			<div class="single-checkbox">
			    <input type="checkbox" id="chk1"> 
			    <label for="chk1">Check it!</label>
			</div>
		</div>
		<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
		<script>
			
		</script>
	</body>
</html>

Open in new window

0
robrodpAuthor Commented:
jquery gives me starnge resulras it is too browser dependent.

Id rather use checkboxes ia a more traditional way so I have no problems with my users.

And in México I am definitely concerned with ie 8 and lower
0
Kyle HamiltonData ScientistCommented:
jquery is not browser dependent. if you are running into issues in ie 11 it's or some other reason.

If you want to use traditional checkboxes in IE less than 8 then you will not be able to style them, and to try to hack something together for some ancient and inferior browser would not be wise. Let the check boxes fall back to their default look and feel in those browsers.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
CSS

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.