zoukankan      html  css  js  c++  java
  • 纯css切换左侧菜单

    <!DOCTYPE html>
    <html>
    <head>
        <meta charset="utf-8">
        <title></title>
        <style>
            * {
                margin: 0;
                padding: 0;
            }
            body,
            html {
                overflow-x: hidden;
            }
            .sidebar {
                -webkit-transition: all .3s ease-in-out;
            }
            .sidebar-toggle,
            .wrap {
                -webkit-transition: -webkit-transform .3s ease-in-out;
            }
            .sidebar-checkbox {
                display: none;
            }
            .wrap {
                padding: 50px 8px;
            }
            .sidebar {
                position: fixed;
                top: 0;
                bottom: 0;
                left: -200px;
                width: 200px;
                background: gray;
            }
            .sidebar-toggle {
                position: fixed;
                top: 8px;
                left: 8px;
                width: 30px;
                height: 30px;
                border-radius: 3px;
            }
            .sidebar-toggle span,
            .sidebar-toggle span:before,
            .sidebar-toggle span:after {
                position: absolute;
                width: 20px;
                height: 2px;
                background: green;
            }
            .sidebar-toggle span {
                top: 14px;
                left: 5px;
            }
            .sidebar-toggle span:before {
                content: '';
                left: 0;
                top: -7px;
            }
            .sidebar-toggle span:after {
                content: '';
                left: 0;
                top: 7px;
            }
            #sidebar-checkbox:checked~.sidebar,
            #sidebar-checkbox:checked~.sidebar-toggle,
            #sidebar-checkbox:checked~.wrap {
                -webkit-transform: translateX(200px);
            }
            #sidebar-checkbox:checked~.sidebar-toggle {
                background: green;
            }
            #sidebar-checkbox:checked~.sidebar-toggle span,
            #sidebar-checkbox:checked~.sidebar-toggle span:before,
            #sidebar-checkbox:checked~.sidebar-toggle span:after {
                background: white;
            }
        </style>
    </head>
    <body>
        <input type="checkbox" class="sidebar-checkbox" id="sidebar-checkbox">
        <div class="sidebar" id="sidebar">sidebar</div>
        <div class="wrap">wrap</div>
        <label for="sidebar-checkbox" class="sidebar-toggle">
            <span></span>
        </label>
    </body>
    </html>
  • 相关阅读:
    你可能不知道的js -- 数据类型转换
    项目开发过程中使用工具的相关配置 -- git / svn / 谷歌跨域
    博客园个人博客页面主题
    keep-alive指定条件缓存的坑
    element的多文件上传
    谷歌应用商店扩展程序
    从郭建的遭遇(自称最惨的创业者)看‘程序员的人生观’(一)
    我深表遗憾
    入门学习三
    编程入门学习二
  • 原文地址:https://www.cnblogs.com/jzm17173/p/4668067.html
Copyright © 2011-2022 走看看