css实现checkbox胶囊开关效果代码

代码语言:html

所属分类:表单美化

代码描述:css实现checkbox胶囊开关效果代码

代码标签: 胶囊 开关 效果

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

<!DOCTYPE html>
<html lang="en">

<head>

    <meta charset="UTF-8">



    <style>
        body {
            font-family: -apple-system, BlinkMacSystemFont,"Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
            display: flex;
            align-items: center;
            justify-content: center;
            height: 100vh;
            background: #e1eef6;
        }

        legend {
            position: absolute;
            opacity: 0;
            z-index: -2;
            width: 1px;
            height: 1px;
            -webkit-user-select: none;
            -moz-user-select: none;
            -ms-user-select: none;
            user-select: none;
        }

        fieldset {
            max-width: 450px;
            width: 100%;
                border: none;
        }

        label {
            display: flex;
            text-transform: uppercase;
            font-size: 48px;
            font-weight: 600;
            -webkit-user-select: none;
            -moz-user-select: none;
            -ms-user-select: none;
            user-select: none;
            align-items: center;
        }
        label:not(:last-child) {
            margin-bottom: 40px;
        }
        label .l {
            margin-left: 20px;
        }

        input {
            opacity: 0;
            position: absolute;
            width: 1px;
            height: 1px;
            z-index: -1;
        }
        input:checked ~ i {
            background: var(--secondary);
        }
        input:checked ~ i:after {
            left: 50%;
            background: var(--primary);
        }

        i {
            outline: 0;
            display: block;
            width: 4em;
            height: 2em;
            position: relative;
            cursor: pointer;
            -webkit-user-select: none;
            -moz-user-select: none;
            -ms-user-select: none;
            user-select: none;
            background: #c9d6de;
            border-radius: 2em;
            padding: 2px;
            transition: all 0.4s ease;
        }
        i:after, i:before {
            position: relative;
            display: block;
            con.........完整代码请登录后点击上方下载按钮下载查看

网友评论0