zoukankan      html  css  js  c++  java
  • h5侧边栏滑动效果 根据Bootstrap3的侧栏导航改编

    主要用到鼠标的 hover 事件,除了点击事件全部 css 完成   根据Bootstrap3的侧栏导航改编

    <style>
            html, body, * {
                margin: 0;
                padding: 0;
            }
    
            #mine {
                position: relative;
                height: 100vh;
                width: 100%;
                background: cadetblue;
            }
    
            #side {
                position: fixed;
                height: 100%;
            }
    
            #toggle_side {
                width: 200px;
                background: #5bc0de;
                cursor: pointer;
                text-align: right;
                display: block;
                transition: all 0.5s ease;
            }
    
            #side_item {
                width: 200px;
                height: 97%;
                background: #30444b;
                text-align: center;
                overflow: hidden;
                transition: all 0.5s ease;
            }
    
            #side_item li {
                line-height: 30px;
                position: relative;
                list-style: none;
                z-index: 0;
                cursor: pointer;
            }
    
            #side_item li a {
                color: aliceblue;
                text-decoration: none;
            }
    
            #side_item li:before {
                background-color: #00b6a8;
                content: '';
                height: 100%;
                left: 0;
                position: absolute;
                top: 0;
                -webkit-transition: width 0.2s ease-in;
                transition: width 0.2s ease-in;
                width: 3px;
                z-index: -1;
            }
    
            #side_item li:hover a {
                color: #e91e63;
                transition: width 0.2s ease-in;
            }
    
            #side_item li:hover:before {
                width: 100%;
            }
    
            #overly {
                width: 100%;
                height: 100%;
                background: rgba(0, 0, 0, 0.5);
                display: block;
                position: fixed;
            }
    
            #container {
                margin-left: 250px;
                transition: all 0.5s ease;
            }
        </style>
    <div id="mine">
        <div id="overly"></div>
        <aside id="side">
            <i id="toggle_side">X</i>
            <div id="side_item">
                <ul>
                    <li><a href="#">11</a></li>
                    <li><a href="#">22</a></li>
                    <li><a href="#">33</a></li>
                    <li><a href="#">44</a></li>
                    <li><a href="#">55</a></li>
                </ul>
            </div>
        </aside>
        <div id="container">
            <div class="row">
            </div>
        </div>
    </div>
    <script>
        var isClosed = true;
        $("#toggle_side").on('click', function () {
            if (isClosed) {
                $("#side_item").css('width', '0px');
                $("#toggle_side").css('width', '10px');
                $("#container").css('margin-left', '50px');
                $("#overly").hide();
                isClosed = false
            } else {
                $("#side_item").css('width', '200px');
                $("#toggle_side").css('width', '200px');
                $("#container").css('margin-left', '250px');
                $("#overly").show();
                isClosed = true
            }
        })
    </script>
  • 相关阅读:
    Asp.Net多线程用法1
    Asp.Net操作FTP方法
    django 利用PIL 保存图片
    django —— Celery实现异步和定时任务
    豆瓣源安装requirements.txt
    一个有趣的python排序模块:bisect
    Python 多线程
    python list元素为dict时的排序
    python版本坑:md5例子(python2与python3中md5区别)
    单独的 python 脚本文件使用 django 自带的 model
  • 原文地址:https://www.cnblogs.com/caoxen/p/11543778.html
Copyright © 2011-2022 走看看