layer移动端案例

本文详细介绍了在移动端项目中使用layer组件的案例,包括如何引入、配置,以及在各种场景下如弹窗、提示信息、加载动画等的实战经验。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <meta http-equiv='Content-Type' content='text/html;charset=UTF-8' />
    <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1" />
    <script src="http://libs.baidu.com/jquery/1.9.0/jquery.js"></script>
    <script src="layer_mobile/layer.js"></script>
    <!--<link rel="stylesheet" href="layer_mobile/need/layer.css">-->
    <style>
        html,body{
            width: 100%;
            height: 100%;
            margin: 0;
            padding: 0;
        }
        ul{
            margin: 0;
            padding: 0;
        }
        ul li{
            list-style-type:none;
        }
        .popuo-login footer{
            width: 100%;
        }
        .popuo-login footer{
            position: fixed;
            left: 0;
            bottom: 0;
            height: 40px;
            line-height: 40px;
        }
        .popuo-login footer li{
            width: 50%;
            float: left;
            text-align: center;
            color: white;
            font-size: 16px;
        }
        .popuo-login footer li:nth-child(1){
            background-color: red;
        }
        .popuo-login footer li:nth-child(2){
            background-color: green;
        }
    </style>
</head>
<body>
    <button class="ck">点击</button>
    <script>
        $(function(){
            var pageii;

            $('.ck').click(function(){
                var content='<ul>' +
                                '<li>1</li>' +
                                '<li>2</li>' +
                            '</ul>' +
                            '<footer>' +
                                '<ul>' +
                                    '<li class="close">取消</li>'+
                                    '<li class="ok">确认</li>'
                                '</ul>' +
                            '</footer>';

                pageii = layer.open({
                    type: 1
                    ,content: content
                    ,anim: 'up'
                    ,className: 'popuo-login'
                    ,style: 'position:fixed; left:0; top:0; width:100%; height:100%; border: none; -webkit-animation-duration: .5s; animation-duration: .5s;'
                });
            })

            //取消
            $('body').on('click','.close',function(){
                layer.close(pageii);
            })
            //确认
            $('body').on('click','.ok',function(){
                console.log('ok');
            })
        })
    </script>
</body>
</html>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值