Home > Web Front-end > CSS Tutorial > Pure css to achieve box selection effect

Pure css to achieve box selection effect

王林
Release: 2020-11-09 15:41:17
forward
4974 people have browsed it

Pure css to achieve box selection effect

Selector introduction:

1. " ": For example, div p selects all

elements immediately after the

element.

2. :checked: For example, input:checked indicates the checked status of radio buttons and check boxes.

(Learning video sharing: css video tutorial)

Implementation code:

<style type="text/css">
            .che-box {
            display:inline;
        }
        .che-box input{
            display: none;
        }
        .che-box label{
            display: inline-block;
            border: 1px solid #e1e1e1;
            border-radius: 4px;
            padding: 3px 5px;
        }
        .che-box input:checked + label{
            border-color: #088de8;
            background: #088de8;
            color: #fff;
        }
    </style>
 
 
<div class="che-box">
        <input type="checkbox" id="che1" />
        <label for="che1">
            标签1
        </label>
    </div>
    <div class="che-box">
        <input type="checkbox" id="che2" />
        <label for="che2">
            标签2
        </label>
    </div>
Copy after login

Implementation effect:

Pure css to achieve box selection effect

This situation is mainly used for customizing the selection style of the input with type="checkbox, radio". It is often used in actual work. I hope it will be helpful to everyone.

Related recommendations: CSS tutorial

The above is the detailed content of Pure css to achieve box selection effect. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
css
source:csdn.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template