CSS checkbox and radio button
How do I make an css checkbox and radio button?
What is a css checkbox and radio button? How do you make a css checkbox and radio button? This script and codes were developed by Andreas Nylin on 30 September 2022, Friday.
CSS checkbox and radio button - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>CSS checkbox and radio button</title> <link rel="stylesheet" href="css/style.css">
</head>
<body> <p> <span class="radio"> <input type="radio" id="my-radio" /> <label for="my-radio"></label> </span> <label for="my-radio">Radio button</label>
</p>
<p> <span class="checkbox"> <input type="checkbox" id="my-checkbox" /> <label for="my-checkbox"></label> </span> <label for="my-checkbox">Checkbox</label>
</p>
<p> Radio button group<br /> <div class="radio-group"> <span class="radio"> <input type="radio" id="radio-a" name="radio-group" checked /> <label for="radio-a">Option A</label> </span> <span class="radio"> <input type="radio" id="radio-b" name="radio-group" /> <label for="radio-b">Option B</label> </span> <span class="radio"> <input type="radio" id="radio-c" name="radio-group" /> <label for="radio-c">Option C</label> </span> </div>
</p>
<p> Checkbox group<br /> <div class="checkbox-group"> <span class="checkbox"> <input type="checkbox" id="checkbox-a" name="checkbox-group" checked /> <label for="checkbox-a">Option A</label> </span> <span class="checkbox"> <input type="checkbox" id="checkbox-b" name="checkbox-group" /> <label for="checkbox-b">Option B</label> </span> <span class="checkbox"> <input type="checkbox" id="checkbox-c" name="checkbox-group" /> <label for="checkbox-c">Option C</label> </span> </div>
</p>
<small> Compability: Works in Internet Explorer 9+, Google Chrome, Safari, Firefox, Opera.
</small>
</body>
</html>
CSS checkbox and radio button - Script Codes CSS Codes
/*
* Page style
*/
body { font-family: sans-serif; font-size: 16px; color: #333;
}
small { color: #999;
}
/* * Basic radio button and checkbox */
.radio,
.checkbox { position: relative; display: inline-block; width: 1em; height: 1em; vertical-align: middle; margin: -.4em .4em 0 0;
}
.radio > label,
.checkbox > label { position: absolute; top: 0; left: 0; width: 1em; height: 1em; border: solid 1px #bbb; border-radius: .1em; background: #eee; white-space: nowrap;
}
.radio > label:hover,
.checkbox > label:hover { box-shadow: 0 0 1px 1px rgba(0,0,0,.05), inset 0 0 1px 1px rgba(255,255,255,.1);
}
.radio > label { border-radius: .5em;
}
.radio > :checked + label:after,
.checkbox > :checked + label:after { position: absolute; top: 0; left: 0; right: 0; bottom: 0; margin: auto; content: ' '; background: #bbb; width: .5em; height: .5em; border-radius: .1em;
}
.radio > :checked + label:after { border-radius: .25em;
}
.radio input,
.checkbox input { position: absolute; top: 0; left: 0; opacity: 0;
}
/* * Groups of radio buttons and checkboxes */
.radio-group .radio,
.checkbox-group .checkbox { width: auto; vertical-align: middle; margin: 0;
}
.radio-group .radio > label,
.checkbox-group .checkbox > label { position: relative; width: auto; padding: .4em; margin: 0 -.2em; border-radius: 0;
}
.radio-group .radio:first-child > label,
.checkbox-group .checkbox:first-child > label { margin-left: 0; border-radius: .5em 0 0 .5em;
}
.radio-group .radio:last-child > label,
.checkbox-group .checkbox:last-child > label { margin-right: 0; border-radius: 0 .5em .5em 0;
}
.radio-group .radio > :checked + label,
.checkbox-group .checkbox > :checked + label{ background: #ddd;
}
.radio-group .radio > :checked + label:after,
.checkbox-group .checkbox > :checked + label:after { content: none;
}
Developer | Andreas Nylin |
Username | andreasnylin |
Uploaded | September 30, 2022 |
Rating | 3 |
Size | 2,208 Kb |
Views | 44,528 |
Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!
Name | Size |
CSS 3D Visualizer | 0 Kb |
HTML Dialog Element Test | 2,902 Kb |
Mega Man | 2,844 Kb |
Responsive fixed image, fluid content | 2,056 Kb |
CSS pumpkin generator | 4,657 Kb |
Random Accessible Color Contrast | 3,995 Kb |
CSS SKULL | 2,243 Kb |
CSS 3D Radio buttons | 1,650 Kb |
CSS target the middle element | 1,657 Kb |
Code Monkey | 2,610 Kb |
Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!
Name | Username | Size |
Tree growth tests | Orchard | 3,818 Kb |
STAR WARS LIGHTSABER | Francoiscoron | 4,420 Kb |
Light Switch | Bartuc | 4,933 Kb |
Template | Indra_z85 | 2,323 Kb |
Twinner Spinner II | Katydecorah | 2,974 Kb |
CSS Flip Animation | Bbodine1 | 2,525 Kb |
Fluid Responsive Typography | Jonmilner | 4,205 Kb |
Clock Face Idea | Chrisburnell | 3,196 Kb |
Drawing a Terminal with CSS | Lachlanjc | 3,185 Kb |
FreeCodeCamp - Simon Game | Ivhed | 8,481 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!