<!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>
模态框
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
推荐阅读更多精彩内容
- 在网页中我们经常会用到模态框,一般会用于显示表单或者是提示信息。由于模态框涉及到页面上比较多的交互效果,最简单的交...
- 话不多说,首先你得去bootStrap官网下载很基础的bootStrap包。(www.bootcss.com)引用...
- 务必将模态框的 HTML 代码放在文档的最高层级内(也就是说,尽量作为 body 标签的直接子元素),以避免其他组...
- 项目中用到了模态框和弹出框。模态框:在操作错误或需要提示时弹出,遮罩整个页面,一般显示在整个页面的正中间弹出框:可...