Click here to Skip to main content
15,886,422 members
Articles / Web Development / HTML5
Tip/Trick

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

Rate me:
Please Sign up or sign in to vote.
0.00/5 (No votes)
18 May 2015CPOL 6.6K  

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:

 

C++
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, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
-- There are no messages in this forum --