模态框

作者: As大大 | 来源:发表于2017-07-27 09:51 被阅读0次
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style>
        #mask {position: fixed;bottom: 0;top: 0;right: 0;left: 0;width: 100%;height: 100%;background-color: rgba(0, 0, 0, .8);display: none;z-index: 99999;}
        #mask .container {width: 80%;background-color: #fff;margin: auto;border-radius: 4px;padding: 4px;top: -100%;position: relative;transition: top .5s ease;}
        #mask .container .body-header {border-bottom: 1px solid #ccc;padding: 10px;}
        #mask .container .body-content {padding: 10px;}
        #mask .container .body-content.center {line-height: 50px;}
        #mask .container .body-footer {border-top: 1px solid #ccc;padding: 10px;}
    </style>
</head>

<body>
    <button>modal</button>
    <div id="mask">
        <div class="container">
            <div class="body-header">
                我是头部
            </div>
            <div class="body-content">
                我是内容我是内容我是内容我是内容我是内容我是内容我是内容我是内容我是内容我是内容我是内容我是内容我是内容我是内容我是内容我
            </div>
            <div class="body-footer">
                我是尾部
            </div>
        </div>
    </div>
    <script src="https://cdn.bootcss.com/zepto/1.2.0/zepto.min.js"></script>
    <script>
    $(function() {
        var $mask = $('#mask');
        var $mask_container = $mask.find('.container');
        $('body').on('touchstart', 'button', function(event) {
            $mask.css({ 'display': 'flex' })
            setTimeout(function() {
                $mask_container.css('top', '0px')
            }, 1)
            event.stopPropagation();
        })

        $('body').on('touchstart', '#mask .container', function(event) {
            $mask_container.css('top', '-100%')
            event.stopPropagation();
        },false)

        $(document).on('touchstart', function() {
            $mask.css('display', 'none')
            $mask_container.css('top', '-100%')
        })
    })
    </script>
</body>

</html>

相关文章

  • 第十三节 MFC的一些概念

    一、模态对话框和非模态对话框Windows对话框分为两类:模态对话框和非模态对话框。模态对话框是这样的对话框,当它...

  • element-ui dialog组件嵌套bug

    模态框嵌套模态框 只需在子集的模态框里面添加append-to-body 就可以了 父级模框 子集模态框 我这样嵌...

  • 进阶任务10-事件应用

    实现Tab切换的功能 实现下图的模态框功能,点击模态框不隐藏,点击关闭以及模态框以外的区域模态框隐藏

  • bootstrap模态框多层嵌套,背景滚动

    问题:在弹出模态框A的基础上,弹出模态框B,关闭模态框B之后,模态框A不能滚动(由于A模块框内容) 造成的原因:遮...

  • 事件的应用

    1. 实现如下图Tab切换的功能 2. 实现下图的模态框功能,点击模态框不隐藏,点击关闭以及模态框以外的区域模态框隐藏

  • 进阶任务10

    1.实现如下图Tab切换的功能 2.实现下图的模态框功能,点击模态框不隐藏,点击关闭以及模态框以外的区域模态框隐藏

  • 事件的应用

    1.实现如下图Tab切换的功能: 2.实现下图的模态框功能,点击模态框不隐藏,点击关闭以及模态框以外的区域模态框隐藏

  • 小程序自定义模态框model

    自定义模态框,点击左侧模态框可以关闭显示

  • 原生JS实现:Tap效果,模态框效果

    Tap效果 代码: Tap效果预览 模态框效果 代码: 模态框效果预览

  • CSS 中的层叠上下文

    在使用 bootstrap 的模态框时,出现了半透明遮罩始终盖住模态框的情况,只有把模态框的 HTML 写到 bo...

网友评论

      本文标题:模态框

      本文链接:https://www.haomeiwen.com/subject/xyaakxtx.html