Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

APS.NET Custom CheckBox CSS whitout javascript / Checkbox css personalizado sin javascript

0.00/5 (No votes)
18 May 2015 1  

Introduction

There is a way to customize the checkbox using only css and whitout javascript.

Using the code

An Asp:Checkbox is composed of a label and an input type check (In html). So you need to use a plus (+) selector in css:

 

input[type=checkbox] { display:none; } /*first hide check control*/

input[type=checkbox] + label:before { /*using font awesome for icons.*/
font-family: FontAwesome;
display: inline-block;
}

input[type=checkbox] + label:before { content: "\f096"; } /* icon when uncheck*/

input[type=checkbox]:checked + label:before { content: "\f046"; } /* icon when check*/

And that's it. You can use css classes just putting the class name first (something like .myCheck input[type=checkbox]...............). and then using it in CssClass property.

You must have this font to use it. You can use also image icons, just change content property, it can be whatever you want.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here