前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >CSS 3.0实现会发光复选框

CSS 3.0实现会发光复选框

作者头像
越陌度阡
发布2020-11-26 10:32:22
4400
发布2020-11-26 10:32:22
举报

给大家分享一个用CSS 3.0实现的会发光的复选框特效,效果如下:

在这里插入图片描述
在这里插入图片描述

以下是代码实现,欢迎大家复制粘贴和收藏。

代码语言:javascript
复制
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>CSS 3.0实现会发光复选框</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            font-family: '微软雅黑', sans-serif;
        }

        body {
            display: flex;
            align-items: center;
            justify-content: center;
            min-height: 100vh;
            background: #191919;
            overflow: hidden;
            flex-direction: column;
        }

        label {
            position: relative;
            width: 240px;
            height: 80px;
            cursor: pointer;
            margin: 20px 0;
        }

        label input {
            opacity: 0;
        }

        label .check {
            position: absolute;
            top: 0;
            left: 0;
            cursor: pointer;
            width: 100%;
            height: 100%;
            background: #101010;
            border-radius: 40px;
            box-shadow: 0 0 0 4px #101010;
        }

        label .check::before {
            content: '';
            position: absolute;
            top: calc(50% - 4px);
            left: -30px;
            width: 8px;
            height: 8px;
            border-radius: 50%;
            background: #f00;
            transition: 0.5s;
            box-shadow: 0 0 5px #f00,
                0 0 10px #f00,
                0 0 20px #f00,
                0 0 40px #f00,
                0 0 80px #f00;
        }

        label input:checked~.check::before {
            background: #101010;
            box-shadow: none;
        }

        label .check::after {
            content: '';
            position: absolute;
            top: calc(50% - 4px);
            right: -30px;
            width: 8px;
            height: 8px;
            border-radius: 50%;
            box-shadow: none;
            transition: 0.5s;
            background: #101010;
        }

        label input:checked~.check::after {
            background: #0f0;
            box-shadow: 0 0 5px #0f0,
                0 0 10px #0f0,
                0 0 20px #0f0,
                0 0 40px #0f0,
                0 0 80px #0f0;
        }

        label .btn {
            position: absolute;
            top: 0;
            left: 0;
            width: 120px;
            height: 80px;
            border-radius: 40px;
            background: #333;
            transition: 0.5s;
            box-shadow: inset 0 -20px 15px #292929,
                inset 0 20px 15px #292929;
        }

        label .btn::before {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            width: 52px;
            height: 80px;
            background: #252525;
            border-top-left-radius: 80px;
            border-bottom-left-radius: 80px;
            filter: blur(2);
        }

        label .btn::after {
            content: '';
            position: absolute;
            top: 0;
            right: 0;
            width: 52px;
            height: 80px;
            background: #252525;
            border-top-right-radius: 80px;
            border-bottom-right-radius: 80px;
            filter: blur(2);
        }

        label input:checked~.btn {
            left: 50%;
        }
    </style>
</head>

<body>
    <label>
        <input type="checkbox" name="">
        <span class="check"></span>
        <span class="btn"></span>
    </label>
    <label>
        <input type="checkbox" name="" checked>
        <span class="check"></span>
        <span class="btn"></span>
    </label>
</body>
</html>
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2020/06/02 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档