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
The WeChat mini-program native components camera,...
Configure Mysql master-slave service implementati...
Table of contents 1. Check the MySQL status in th...
Table of contents 1. What is a calculated propert...
This article shares the specific code of JavaScri...
When using SQL to extract data, we often encounte...
Table of contents 1 Introduction 2 Trigger Introd...
1. Phenomenon In the early morning, an index was ...
When making some pages, in order to make the page...
Table of contents Prerequisites Setting up a test...
We have introduced how to create a waterfall layo...
1. First look at the request configuration file, ...
mysqldump command Introduction: A database backup...
This article shares the specific code of js to im...
If you are not committed to becoming an artist, t...