How we can customize HTML radio buttons or checkboxes? Answer: Check out This CSS Custom Checkbox And Radio Buttons, HTML Stylish Radio Button.
You must have seen radio buttons or checkbox before. If you don’t know what is HTML radio buttons, You must have seen the empty circle field or checkbox on multiple choice question. They called radio in HTML and web languages. Buy those buttons are non-stylish by default.
But you can change the layout or style of the radio buttons and checkboxes. But now the question is how we can change the style of those buttons. Yes, you can do it easily if you seeing this post. Because today I am sharing a solution to this. So, Today I am sharing the CSS Custom Checkbox And Radio Buttons program. In other words, HTML Stylish Radio Buttons.
We can call this a Pure CSS Custom Radio Buttons and Checkbox. You can use this on your website’s feedback form or something else. You can also customize this as your choice, after a few changes of CSS codes. Also, a beginner can understand the whole program after seeing the code. This is a good example of how we can use CSS.
If you are thinking now how this program looks like. Then see the preview given below.
Preview Of HTML Stylish Radio Button
See this video preview to getting an idea of how this program actually is.
Now you can see this program visually. If you like this, then get the source code of its.
You May Also Like:
CSS Custom Checkbox Source Code
Before sharing source code, let’s talk about this program. As you know this is a pure CSS custom checkbox and radio buttons program. For creating this program, I used HTML for
attribute (get info). For styling the radio buttons I used CSS [type="radio"]
command for giving effect to each radio. This program is a perfect example of the power of CSS3.
For creating this program, you have to create only 2 files. One for HTML, and one for CSS. Follow the steps to creating this without any error.
index.html
Create an HTML file named ‘index.html‘ and put these codes given here below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
<!DOCTYPE html> <!-- code by webdevtrick ( https://webdevtrick.com ) --> <html lang="en" > <head> <meta charset="UTF-8"> <title>CSS Custom Checkbox | Webdevtrick.com</title> <link rel="stylesheet" href="style.css"> </head> <body> <fieldset> <legend>CSS Stylish Radio Buttons</legend> <label for="webdesign"> <input type="radio" value="design" name="radiob" id="webdesign" checked> <span>Web Design</span> </label> <label for="webdevelopment"> <input type="radio" value="webdevelopment" name="radiob" id="webdevelopment"> <span>Web Development</span> </label> <label for="seo"> <input type="radio" value="seo" name="radiob" id="seo"> <span>SEO</span> </label> </fieldset> </body> </html> |
style.css
Now create a CSS file named ‘style.css‘ and put these codes.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
/** code by webdevtrick ( https://webdevtrick.com ) **/ @import url(https://fonts.googleapis.com/css?family=Staatliches&display=swap); body { margin: 8em auto; max-width: 30em; font-family: 'Staatliches', cursive; } [type="radio"] { border: 0; clip: rect(0 0 0 0); height: 1px; margin: -1px; overflow: hidden; padding: 0; position: absolute; width: 1px; } label { display: block; cursor: pointer; line-height: 2.5; font-size: 1.5em; } [type="radio"] + span { display: block; } [type="radio"] + span:before { content: ''; display: inline-block; width: 1em; height: 1em; vertical-align: -0.25em; border-radius: 1em; border: 0.125em solid #fff; box-shadow: 0 0 0 0.15em #000; margin-right: 0.75em; transition: 0.5s ease all; } [type="radio"]:checked + span:before { background: #ea4b3c; box-shadow: 0 0 0 0.25em #000; } [type="radio"]:focus + span:after { content: '\00AB'; font-size: 1.5em; line-height: 1; vertical-align: -0.125em; color: #ea4b3c; } fieldset { font-size: 1em; border: 2px solid #000; padding: 2em; border-radius: 0.5em; } legend { color: #fff; background: #000; padding: 0.25em 1em; border-radius: 1em; } |
That’s It. You have successfully created a CSS Custom Checkbox and HTML Stylish Radio Buttons. If you have any doubt or question then comment down below.
Thanks For Visiting, Keep Visiting.
Awesome check box button
Thank you very much, Tarun.
It look much better then mine
Hey! thank you very much.
Hey.. can please guide me how to make online quiz using Angular Js ?
Wow, Awesome check boxes
Thank You Very Much.
It’s really an interesting checkbox and definitely, I will try this feature soon