
- CSS Tutorial
- CSS - Home
- CSS - Introduction
- CSS - Syntax
- CSS - Inclusion
- CSS - Measurement Units
- CSS - Colors
- CSS - Backgrounds
- CSS - Fonts
- CSS - Text
- CSS - Images
- CSS - Links
- CSS - Tables
- CSS - Borders
- CSS - Margins
- CSS - Lists
- CSS - Padding
- CSS - Cursors
- CSS - Outlines
- CSS - Dimension
- CSS - Scrollbars
- CSS Advanced
- CSS - Visibility
- CSS - Positioning
- CSS - Layers
- CSS - Pseudo Classes
- CSS - Pseudo Elements
- CSS - @ Rules
- CSS - Text Effects
- CSS - Media Types
- CSS - Paged Media
- CSS - Aural Media
- CSS - Printing
- CSS - Layouts
- CSS - Validations
- CSS3 Tutorial
- CSS3 - Tutorial
- CSS3 - Rounded Corner
- CSS3 - Border Images
- CSS3 - Multi Background
- CSS3 - Color
- CSS3 - Gradients
- CSS3 - Shadow
- CSS3 - Text
- CSS3 - Web font
- CSS3 - 2d transform
- CSS3 - 3d transform
- CSS3 - Animation
- CSS3 - Multi columns
- CSS3 - User Interface
- CSS3 - Box Sizing
- CSS Responsive
- CSS - Responsive Web Design
- CSS References
- CSS - Questions and Answers
- CSS - Quick Guide
- CSS - References
- CSS - Color References
- CSS - Web browser References
- CSS - Web safe fonts
- CSS - Units
- CSS - Animation
- CSS Resources
- CSS - Useful Resources
- CSS - Discussion
How to create custom checkboxes and radio buttons with CSS?
Following is the code to create a responsive navigation menu with a login form inside of it −
Example
<!DOCTYPE html> <html> <style> .checkboxContainer { display: block; position: relative; padding-left: 35px; margin-bottom: 12px; cursor: pointer; font-size: 22px; -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; } .checkboxContainer input { position: absolute; opacity: 0; cursor: pointer; height: 0; width: 0; } .checkboxMarked { position: absolute; top: 0; left: 0; height: 25px; width: 25px; background-color: #eee; } .checkboxContainer:hover input ~ .checkboxMarked { background-color: rgb(205, 255, 199); } .checkboxContainer input:checked ~ .checkboxMarked { background-color: rgb(5, 170, 32); } .checkboxMarked:after { content: ""; position: absolute; display: none; } .checkboxContainer input:checked ~ .checkboxMarked:after { display: block; } .checkboxContainer .checkboxMarked:after { left: 9px; top: 5px; width: 5px; height: 10px; border: solid white; border-width: 0 3px 3px 0; -webkit-transform: rotate(45deg); -ms-transform: rotate(45deg); transform: rotate(45deg); } </style> <body> <h1>Custom Checkbox Example</h1> <label class="checkboxContainer">Rice <input type="checkbox" checked="checked"> <span class="checkboxMarked"></span> </label> <label class="checkboxContainer">Flour <input type="checkbox"> <span class="checkboxMarked"></span> </label> </body> </html>
Output
This will produce the following output −
- Related Articles
- Custom Radio Buttons with CSS appearance Property
- Preappend or Append radio buttons and checkboxes with Bootstrap
- How to create fading buttons with CSS?
- How to create loading buttons with CSS?
- How to create pill buttons with CSS?
- How to create notification buttons with CSS?
- How to create icon buttons with CSS?
- How to create "next" and "previous" buttons with CSS?
- Create Hoverable Buttons with CSS
- How to create custom select boxes with CSS and JavaScript?
- How to create a custom scrollbar with CSS?
- How to dynamically create radio buttons using an array in JavaScript?
- How to Disable Radio Buttons using JavaScript?
- How to create custom range sliders with CSS and JavaScript?\n\n
- How to create Custom Cursor using CSS

Advertisements