Pure CSS3 beautifies radio and checkbox_html/css_WEB-ITnose
As the title states, the effect of beautifying the radio and checkbox is mainly achieved through CSS3, but the compatibility is not very good. The PC only supports the Chrome browser (IE and Firefox tests are not possible, and there are no more tests on others). Then access to WeChat and QQ is also normal. Since the functions provided by LZ only need to be displayed on WeChat, we did not study them in depth.
Of course, although it is not compatible, there is still a need to explain why it is not compatible. The key lies in the problem of such a selector: input[type=radio]:before . The pseudo-class selector :beofre can insert some styles in P, span, div and other tags in mainstream browsers, but it cannot be used in input. Chrome simply supports this feature, and this example is based on this feature. development. Not much else to say, just the code and screenshots.
Screenshot of the effect:
HTML code:
<label for="test1">Test for test1 </label> <input class="radio" type="radio" ID="test1" name="test" value="test1"/> <label for="test2">Test for test2 </label> <input class="radio" type="radio" ID="test2" name="test" value="test2"/> <br> <br> <br> <label for="check1">check1</label> <input id="check1" name="check" value="check1" type="checkbox" class="checkbox"/> <label for="check2">check2</label> <input id="check2" name="check" value="check2" type="checkbox" class="checkbox"/> <label for="check3">check3</label> <input id="check3" name="check" value="check3" type="checkbox" class="checkbox"/> <label for="check4">check4</label> <input id="check4" name="check" value="check4" type="checkbox" class="checkbox"/>
Then the CSS code:
input[type=radio]{ font-size:1em; visibility: hidden; position: relative; display: inline-block; width: 1em; height: 1em; } input[type=radio]:before{ font-size:1em; top:12%; display: inline-block; position: absolute; content:' '; visibility: visible; height: 1em; width: 1em; display: block; background: url("../img/no.png") no-repeat; background-size: 1em 1em; } input[type=radio]:checked:before{ font-size:1em; content:' '; visibility: visible; height: 1em; width: 1em; background: url("../img/yes.png") no-repeat; background-size: 1em 1em; } input[type=checkbox]{ font-size:1em; visibility: hidden; position: relative; display: inline-block; width: 1em; height: 1em; } input[type=checkbox]:before{ top:12%; display: inline-block; position: absolute; content:' '; visibility: visible; height: 1em; width: 1em; display: block; background: url("../img/checkbox_no.png") no-repeat; background-size: 1em 1em; } input[type=checkbox]:checked:before{ content:' '; visibility: visible; height: 1em; width: 1em; background: url("../img/checkbox.png") no-repeat; background-size: 1em 1em; }
Copyright statement: This article is an original article by the blogger, No reproduction is allowed without the permission of the blogger.

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



The article discusses the HTML <progress> element, its purpose, styling, and differences from the <meter> element. The main focus is on using <progress> for task completion and <meter> for stati

The article discusses the HTML <datalist> element, which enhances forms by providing autocomplete suggestions, improving user experience and reducing errors.Character count: 159

Article discusses best practices for ensuring HTML5 cross-browser compatibility, focusing on feature detection, progressive enhancement, and testing methods.

The article discusses the HTML <meter> element, used for displaying scalar or fractional values within a range, and its common applications in web development. It differentiates <meter> from <progress> and ex

The article discusses using HTML5 form validation attributes like required, pattern, min, max, and length limits to validate user input directly in the browser.

The article discusses the viewport meta tag, essential for responsive web design on mobile devices. It explains how proper use ensures optimal content scaling and user interaction, while misuse can lead to design and accessibility issues.

The article discusses the <iframe> tag's purpose in embedding external content into webpages, its common uses, security risks, and alternatives like object tags and APIs.

GiteePages static website deployment failed: 404 error troubleshooting and resolution when using Gitee...
