zoukankan      html  css  js  c++  java
  • 抽屉式性别(男女)选择

    代码:

    <!DOCTYPE html>
    <html lang="zh-CN">
    
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" />
        <title>Document</title>
        <style type="text/css">
        * {
            margin: 0;
            padding: 0;
        }
        
        body {
            max-width: 640px;
            margin: 0 auto;
             background: #52007c;
     
        }
        .J_sex{ padding:30px 5px; }
        
        .downNav span {
            display: inline-block;
            width: 96%;
            height: 50px;
            margin-left: 2%;
            line-height: 50px;
            border-bottom: 1px solid #f5f5f5;
            text-align: center;
        }
        
        .downNav span:hover {
            background-color: #f5f5f5;
        }
        
        .downNav {
            width: 100%;
            height: 40%;
            background-color: #fff;
            position: fixed;
            z-index: 999;
            bottom: -40%;
        }
        
        .input {
            width: 39%;
            height: 25px;
            line-height: 25px;
            border-radius: 5px;
            background-color: #fff;
            padding: 0 5px;
            box-sizing: border-box;
            display: block;
            float: left;
        }
        
        .pf_body li span {
            display: inline-block;
        }
        
        .pfb_list {
            width: 22%;
            text-align: center;
            float: left;
            color: #fff;
        }
        .input em{ font-style: normal; display: inline-block; width: 100%; height: 25px;line-height: 25px;}
        </style>
    </head>
    
    <body>
        <div class="J_sex">
            <div class="input">
                <em class=" J_sex_down"></em>
                <input type="hidden" name="biz_user_sex" value="1" />
            </div>
            <span class="pfb_list">性别</span>
            <div class="input">
                <em class=" J_sex_down"></em>
                <input type="hidden" name="biz_user_sex2" value="1" />
            </div>
        </div>
        <!-- 性别弹窗 -->
        <div class="bgDiv" id="bgDiv"></div>
        <div class="downNav" id="downNav">
            <span data-value="1"></span>
            <span data-value="0"></span>
        </div>
        <script src="http://apps.bdimg.com/libs/jquery/1.9.1/jquery.min.js" type="text/javascript"></script>
        <script type="text/javascript">
        $(function() {
            // 性别
            var sex_down = $('.J_sex_down');
            var bg = $('#bgDiv');
            var downNav = $('#downNav');
            sex_down.on('click', function() {
                $(this).parent().addClass("current");
                bg.css({
                    display: "block",
                    transition: "opacity .5s"
                });
                downNav.css({
                    bottom: "0px",
                    transition: "bottom 1s"
                });
                $('#downNav span').on('click', function() {
                    hideNav();
                    var value = $(this).data('value');
                    $(".J_sex .current").find("em").text($(this).html())
                        .parent().find('input').val(value)
                        .parent().removeClass("current");
                });
            });
    
            bg.on('click', function() {
                hideNav();
            });
    
            function hideNav() {
    
                downNav.css({
                    bottom: "-50%",
                    webkitTransition: "bottom .5s",
                    oTransition: "bottom .5s",
                    mozTransition: "bottom .5s",
                    transition: "bottom .5s"
                });
                bg.css({
                    display: "none",
                    transition: "display 1s"
                });
            }
        });
        </script>
    </body>
    
    </html>

    效果图:

  • 相关阅读:
    prettier 与 eslint 对比
    vscode快捷键补充
    什么是函数式编程
    让Chrome看不了WWDC直播的HLS技术详解
    IPv6启动五年后,距离我们究竟还有多远?
    WebSocket+MSE——HTML5 直播技术解析
    为什么各大厂商要抢先跟进H.265?
    如何通过 WebP 兼容减少图片资源大小
    IPv6,AppStore 审核不是唯一选择它的原因
    为什么非全站升级HTTPS不可?
  • 原文地址:https://www.cnblogs.com/huanghuali/p/6733710.html
Copyright © 2011-2022 走看看