radio-and-checkbox Pure CSS to achieve radio and checkbox effects reset-radio When developing PC projects, radio and checkbox components are often used. However, because the native styles are relatively inconsistent with the designer's design style, we may often reference third-party modules to implement them, or hack them through other methods such as JS. This not only increases the amount of code, but is also very complicated, so there is this pure CSS implementation that relies on native input[radio] and input[checkbox]. The main code is as follows: HTML main code <div class="reset-radio"> <input checked type="radio" id="age1" name="age"> <span class="real-target"></span> </div> CSS code, here mainly through a child node span to cooperate with the input: checked brother selector to modify the style .reset-radio { display: inline-block; position: relative; width: 16px; height: 16px; } .reset-radio .real-target { z-index: 1; width: 100%; height: 100%; position: absolute; display: inline-block; background: #ffffff; border: 1px solid #dadde0; border-radius: 100%; top: 0; left: 0; bottom: 0; } .reset-radio input[type=radio] { cursor: pointer; z-index: 2; width: 16px; height: 16px; opacity: 0; position: absolute; left: 0; top: 0; margin: 0; right: 0; bottom: 0; } .reset-radio input:checked+span { border-color: #48b4ec; } .reset-radio input:checked+span::before { content: ''; position: absolute; background: #48b4ec; width: 6px; height: 6px; top: 50%; left: 50%; transform: translate(-50%, -50%); border-radius: 100%; } reset-checkbox The principle of reset-checkbox is the same, so I won't go into details. The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM. |
<<: Definition and usage of MySQL cursor
>>: Brief analysis of the introduction and basic usage of Promise
Table of contents 1. Official Documentation 2. Cr...
/******************** * Virtual File System VFS *...
First we create the database table: CREATE TABLE ...
Table of contents Difference between MVC and MVVM...
For example, there is an input box <el-input r...
Table of contents 1. mixin.scss 2. Single file us...
HTML img produces an ugly blue border after addin...
Under Linux, if you download and install an appli...
Preface When developing a gateway project, the si...
If you use docker search centos in Docker Use doc...
1. How to create a user and password 1. Enter the...
This article uses examples to illustrate the usag...
In desperation, I suddenly thought, how is the Sin...
After pressing Enter on the webpage, the form is a...
Table of contents map filter some every findIndex...