CSS checkbox and radio button

Developer
Size
2,208 Kb
Views
44,528

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 Previews

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;
}
CSS checkbox and radio button - Script Codes
CSS checkbox and radio button - Script Codes
Home Page Home
Developer Andreas Nylin
Username andreasnylin
Uploaded September 30, 2022
Rating 3
Size 2,208 Kb
Views 44,528
Do you need developer help for CSS checkbox and radio button?

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!

Andreas Nylin (andreasnylin) Script Codes
Create amazing captions with AI!

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!