div+css实现emoji表情checkbox开关效果代码

代码语言:html

所属分类:其他

代码描述:div+css实现emoji表情checkbox开关效果代码

代码标签: div css emoji 表情 checkbox 开关

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

<html lang="en">

<head>

    <meta charset="UTF-8">
    <style>
        .emoji-toggle {
            position: relative;
            width: 60px;
            margin: 40px auto
        }
        
        .emoji-toggle .well {
            display: block;
            background: #eee;
            height: 20px;
            border-radius: 10px;
            cursor: pointer
        }
        
        .emoji-toggle .toggle {
            opacity: 0;
            border: 0;
            outline: 0;
            height: 100%;
            width: 100%;
            background: transparent;
            position: absolute;
            cursor: pointer;
            z-index: 100
        }
        
        .emoji-toggle .toggle ~ .emoji:before {
            content: "🐱";
            position: absolute;
            left: 0;
            top: -15px;
            font-size: 40px;
            transition: .2s
        }
        
        .emoji-toggle .toggle:checked ~ .emoji:before {
            left: 100%;
            margin-left: -1em
        }
        
        .emoji-toggle .toggle ~ label {
            white-space: nowrap
        }
        
        .emoji-toggle .toggle ~ label:before {
            position: absolute;
            right: 100%;
            margin-right: 5px;
            top: 0
        }
        
        .emoji-toggle .toggle ~ label:after {
            position: absolute;
            left: 100%;
            margin-left: 5px;
            top: 0
        }
        
        .emoji-happy .toggle ~ .emoji:before {
            content: "😄"
        }
        
        .emoji-happy .toggle:checked ~ .emoji:before {
            content: "😠"
        }
        
        .emoji-happy .toggle ~ label:before {
            content: "Happy"
        }
        
        .emoji-happy .toggle ~ label:after {
            content: "Mad"
        }
        
        .emoji-travel .toggle ~ .emoji:before {
            content: "✈"
        }
        
        .emoji-travel .toggle:checked ~ .emoji:before {
            content: "🚃"
        }
        
        .emoji-travel .toggle ~ label:before {
            content: "Plane"
        }
        
        .emoji-travel .toggle ~ label:after {
            content: "Train"
        }
        
        .emoji-food .toggle ~ .emoji:before {
            content: "🍔"
        }
        
        .emoji-food .toggle:checked ~ .emoji:before {
            content: "🍕"
        }
        
        .emoji-food ..........完整代码请登录后点击上方下载按钮下载查看

网友评论0