课时8—弹窗modal
首先弹窗的实现效果如下:

主要实现的代码如下:
CSS:
.header,.footer,.wrap-page{
position:absolute;
left:;
right:;
background-color: #fff;
}
.header,.footer{
height:44px;
background-color: #fff;
text-align: center;
z-index:;
line-height:44px;
}
.header{
top:;
border-bottom: 1px solid #f00;
}
.footer{
bottom:;
border-top: 1px solid #f00;
}
.page-title{
line-height:44px;
}
.fl{
float:left;
}
.fr{
float: right;
}
.wrap-page{
top: 44px;
bottom:;
overflow-y:auto;
-webkit-overflow-scrolling: touch;
}
.page{
position: relative;
padding: 10px;
}
.page p{
margin-bottom: 10px;
}
.modal-link{
background-color: #f00;
color:#fff;
padding: 10px;
border-radius:3px;
display: inline-block;
cursor: pointer;
}
/* overlay */
.overlay,
.modal .modal-ft {
display: -webkit-box;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
}
.overlay {
position: fixed;
top:;
right:;
bottom:;
left:;
z-index: -1;
background-color: rgba(0, 0, 0, 0.8);
-webkit-box-pack: center;
-ms-flex-pack: center;
-webkit-justify-content: center;
justify-content: center;
-webkit-box-align: center;
-ms-flex-align: center;
-webkit-align-items: center;
align-items: center;
}
.overlay.active {
z-index:;
}
.modal {
-webkit-transition: all 0.3s ease-in-out;
transition: all 0.3s ease-in-out;
}
.modal {
background-color: #fff;
border-radius: 5px;
margin: 0 10px;
overflow: hidden;
opacity:;
-webkit-transform: translate3d(0, 0, 0) scale(0.815);
transform: translate3d(0, 0, 0) scale(0.815);
-webkit-transition-property: -webkit-transform, opacity;
transition-property: transform, opacity;
}
.modal.modal-in {
opacity:;
-webkit-transform: translate3d(0, 0, 0) scale(1);
transform: translate3d(0, 0, 0) scale(1);
}
.modal .modal-hd {
text-align: center;
line-height: 40px;
background-color: #0078e7;
color: #fff;
}
.modal .modal-bd {
padding: 15px;
}
.modal .modal-ft {
border-top: 1px solid #cccccc;
}
.modal .modal-ft .btn-modal {
-webkit-box-flex:;
-ms-flex:;
-webkit-flex:;
flex:;
background-color: #fefefe;
text-align: center;
line-height: 40px;
color: #0078e7;
}
.modal .modal-ft .btn-modal:first-child {
border-right: 1px solid #cccccc;
}
.modal .modal-ft .btn-modal:last-child {
border-right: none;
}
.modal .modal-ft .btn-modal:hover, .modal .modal-ft .btn-modal:active {
background-color: #d9d9d9;
}
HTML:
<header id="header" class="header">
<h1 class="page-title">modal 测试</h1>
</header>
<div id="main" class="wrap-page">
<section class="page">
<p><span class="modal-link" data-modal="modal-test">点击测试 modal</span></p>
<p>君子曰:学不可以已。</p>
</section>
</div>
<div class="overlay" id="overlay">
<section class="modal modal-test" style="display:none;">
<div class="modal-hd">标题</div>
<div class="modal-bd">
<p>1青,取之于蓝,而青于蓝;冰,水为之,而寒于水。故木受绳则直,金就砺则利,君子博学而日参省乎己,则知明而行无过矣。</p>
<p>2青,取之于蓝,而青于蓝;冰,水为之,而寒于水。故木受绳则直,金就砺则利,君子博学而日参省乎己,则知明而行无过矣。</p>
<p>3青,取之于蓝,而青于蓝;冰,水为之,而寒于水。故木受绳则直,金就砺则利,君子博学而日参省乎己,则知明而行无过矣。</p>
</div>
<div class="modal-ft">
<span class="btn-modal">确认</span><span class="btn-modal">取消</span>
</div>
</section>
</div>
JavaScript:
$(function(){
var $overlay = $('#overlay');
function modalHidden($ele) {
$ele.removeClass('modal-in');
$ele.one('transitionend',function(){
$ele.css({"display": "none"});
$overlay.removeClass('active');
});
}
$('.modal-link').tap(function(){
var $that = $(this);
$overlay.addClass('active');
var $whichModal = $('.'+$(this).data('modal'));
$whichModal.animate({"display":"block"},100,function(){
$(this).addClass('modal-in');
});
$('.btn-modal').tap(function(e){
modalHidden($whichModal);
e.stopPropagation();
});
$overlay.tap(function(e){
if(e.target.classList.contains('overlay')){
modalHidden($whichModal);
}
});
});
});
总结:
移动端背景透明度使用rgba,遮盖层和弹出层可以设计成嵌套模式。
课时8—弹窗modal的更多相关文章
- boostrap --- 弹窗modal的使用
<input id="btntext" type="button" value="添加文本组件" data-toggle=" ...
- ng2-bootstrap的modal嵌套时无法滚动的情况
在ng2-bootstrap的弹窗modal中再弹出另外一个弹窗,关闭子弹窗后,父弹窗会出现无法上下滚动的情况. 通过观察样式可知,关闭子弹窗前,父弹窗的body上是有modal-open样式的,关闭 ...
- Bootstrap modal.js 源码分析
/* ======================================================================== * Bootstrap: modal.js v3 ...
- Blazor组件的new使用方式与动态弹窗
1. 前言 在Blazor中的无状态组件文中,我提到了无状态组件中,有人提到这个没有diff,在渲染复杂model时,性能可能会更差.确实,这一点确实是会存在的.以上文的方式来实现无状态组件,确实只要 ...
- Knockout Mvc Compoment FrameSet
Knockout Mvc Compoment FrameSet 框架文件结构 01- 网站(表现层),mvc主要作用视图展示. 02- 模型(Model),主要作用承载视图数据结构,网站前后台 ...
- Bootstrap模态弹出框
前面的话 在 Bootstrap 框架中把模态弹出框统一称为 Modal.这种弹出框效果在大多数 Web 网站的交互中都可见.比如点击一个按钮弹出一个框,弹出的框可能是一段文件描述,也可能带有按钮操作 ...
- what?iView的DropDown没有element的split-button?提issure?等不及了,自己实现一个
开始正文之前,有必要先说自己实现这个组件的必要性描述. 话说大家做表格时,增删查改按钮都是放在哪里的?最简单的方式应该是这样: 是不是感觉奇丑无比啊,于是改成了这样: 但是这种操作按钮一多后就没位置放 ...
- JavaScript 示例
JavaScript 示例 <html lang="en"> <head> <meta charset="UTF-8"> & ...
- 用 Vue 改造 Bootstrap,渐进提升项目框架[转]
GitChat 作者:Meathill 原文:用 Vue 改造 Bootstrap,渐进提升项目框架 关注微信公众号:「GitChat 技术杂谈」 一本正经的讲技术 [不要错过文末彩蛋] 前言 Vue ...
随机推荐
- jq验证码换一换
<!DOCTYPE html><html><head> <meta charset="utf-8"> <meta http-e ...
- 以Debug模式启动JBoss
JBoss服务器的启动方法: 假设JBoss的安装目录为$JBOSS_HOME,Windows以及Linux环境下的Debug模式的启动方法分别为:Windows环境:找到Windows下的JBoss ...
- GIt的命令
Git 命令 1,git init初始化当前文件夹为git仓库的根目录 2.git commit提交到本地仓库 3.git push origin master 提交到服务器 4.git log 查看 ...
- NA
0000-00001000-0000 1111-1111 1*2^7=1281*2^6=641*2^5=321*2^4=161*2^3=81*2^2=41*2^1=21*2^0=1 0000-0010 ...
- paper 95:《模式识别和机器学习》资源
Bishop的<模式识别和机器学习>是该领域的经典教材,本文搜罗了有关的教程和读书笔记,供对比学习之用,主要搜索的资源包括CSDN:http://download.csdn.net/sea ...
- JS中Float类型加减乘除 修复
MXS&Vincene ─╄OvЁ &0000027─╄OvЁ MXS&Vincene MXS&Vincene ─╄OvЁ:今天很残酷,明天更残酷,后天很美好, ...
- WebService处理大数据量数据
在通过WebService处理大数据量数据时出现如下错误: soap fault: 运行配置文件中指定的扩展时出现异常. ---> 超过了最大请求长度. 解决方法: 因为上传的文件大于系统默认配 ...
- C#知识点有必要知会
如果说你父类里面有一个成员比如int a;那么你子类里面也可以再定义一个int a,这个时候base.a和this.a表示的就不是一个变量了,如果说子类里面没有,那么base.a和this.a表示的都 ...
- Linux VFS中write系统调用实现原理【转】
转自:http://blog.chinaunix.net/uid-28362602-id-3425881.html 目录 用户空间的write函数在内核里面的服务例程为sys_write Vfs_wr ...
- Linux top和负载的说明
转自:http://bbs.linuxtone.org/thread-1684-1-1.html top命令是Linux下常用的性能分析工具,能够实时显示系统中各个进程的资源占用状况,类似于Windo ...