css实现五种checkbox切换风格样式效果代码

代码语言:html

所属分类:表单美化

代码描述:css实现五种checkbox切换风格样式效果代码

代码标签: checkbox 切换 风格 样式 效果

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

<html>
<head>
    <style>
        html,
        body {
            display: flex;
            min-height: 100%;
            justify-content: center;
            align-items: center;
            flex-direction: column;
            font-family: sans-serif;
            background-color: #1F1F1F;
        }

        ul,
        li {
            list-style: none;
            margin: 0;
            padding: 0;
        }

        .tg-list {
            text-align: center;
            display: flex;
            align-items: center;
        }

        .tg-list-item {
            margin: 0 2em;
        }

        h2 {
            color: #777;
        }

        h4 {
            color: #999;
        }

        .tgl {
            display: none;
        }
        .tgl, .tgl:after, .tgl:before, .tgl *, .tgl *:after, .tgl *:before, .tgl + .tgl-btn {
            box-sizing: border-box;
        }
        .tgl::-moz-selection, .tgl:after::-moz-selection, .tgl:before::-moz-selection, .tgl *::-moz-selection, .tgl *:after::-moz-selection, .tgl *:before::-moz-selection, .tgl + .tgl-btn::-moz-selection {
            background: none;
        }
        .tgl::selection, .tgl:after::selection, .tgl:before::selection, .tgl *::selection, .tgl *:after::selection, .tgl *:before::selection, .tgl + .tgl-btn::selection {
            background: none;
        }
        .tgl + .tgl-btn {
            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;
        }
        .tgl + .tgl-btn:after, .tgl + .tgl-btn:before {
            position: relative;
            display: block;
            content: "";
            width: 50%;
            height: 100%;
        }
        .tgl + .tgl-btn:after {
            left: 0;
        }
        .tgl + .tgl-btn:before {
            display: none;
        }
        .tgl:checked + .tgl-btn:after {
            left: 50%;
        }

        .tgl-light + .tgl-btn {
            background: #f0f0f0;
            border-radius: 2em;
            padding: 2px;
            transition: all 0.4s ease;
        }
        .tgl-light + .tgl-btn:after {
            border-radius: 50%;
            background: #fff;
            transition: all 0.2s ease;
        }
        .tgl-light:checked + .tgl-btn {
            background: #9FD6AE;
        }

        .tgl-ios + .tgl-btn {
            background: #fbfbfb;
            border-radius: 2em;
            padding: 2px;
            transition: all 0.4s ease;
            border: 1px solid #e8eae9;
        }
        .tgl-ios + .tgl-btn:after {
            border-radius: 2em;
            background: #fbfbfb;
            transition: left 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), padding 0.3s ease, margin 0.3s ease;
            box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.1), 0 4px 0 rgba(0, 0, 0, 0.08);
        }
        .tgl-ios + .tgl-btn:hover:after {
            will-change: padding;
        }
        .tgl-ios + .tgl-btn:active {
            box-shadow: inset 0 0 0 2em #e8eae9;
        }
        .tgl-ios + .tgl-btn:active:after {
            padding-right: 0.8em;
        }
        .tgl-ios:checked + .tgl-btn {
            background: #86d993;
        }
        .tgl-ios:checked + .tgl-btn:active {
            box-shadow: none;
        }
        .tgl-ios:checked + .tgl-btn:active:after {
            margin-left: -0.8em;
        }

        .tgl-skewed + .tgl-btn {
            overflow: hidden;
            transform: skew(-10deg);
            -webkit-backface-visibility: hidden;
            backface-visibility: hidden;
            transition: all 0.2s ease;
            font-family: sans-serif;
            background: #888;
        }
        .tgl-skewed + .tgl-btn:after, .tgl-skewed + .tgl-btn:before {
            transform: skew(10deg);
            display: inline-block;
            transition: all 0.2s ease;
            width: 100%;
            text-align: center;
            position: absolute;
            line-height: 2em;
            font-weight: bold;
            color: #fff;
            text-shadow: 0 1px 0 rgba(0, 0, 0, 0.4);
        }
        .tgl-skewed + .tgl-btn:after {
            left: 100%;
            content: attr(data-tg-.........完整代码请登录后点击上方下载按钮下载查看

网友评论0