html自定义弹框
一、要实现的功能

二、具体实现
<div id="dialogmask" class="dialogmask opacity"></div>
<div id="dialog" class="box" style="display: none">
<div id="dialog_title" class="dialogtitle">
<label style="padding-left: 10px">执行结果</label>
<label style="float: right;padding-right: 10px;" onclick="closelog()">[关闭]</label>
</div>
<div id="dialog_content" class="dialogcontent">
<div id="logcontent" class="logcontent”>要展示的弹框内容</div>
</div>
</div>
.box {
position: absolute;
display: none;
width: 60%;
height: 70%;
z-index: 100; /*值越大,和其他层层叠时越在上面*/
left: 20%;
top: 15%;
background-color: #fff;
border: 1px solid rgb(0, 153, 153);
}
.dialogcontent {
padding-top: 20px;
OVERFLOW: scroll;
height: calc(100% - 20px);
height: -webkit-calc(100% - 20px);
}
.dialogmask {
position: fixed;
top: 0px;
height: 100%;
width: 100%;
z-index: 80;
display: none; } .opacity { /*遮罩浑浊处理*/
opacity: 0.3;
filter: alpha(opacity=30);
background-color: #000;
}
function showlog_result(result, info) {//展示具体日志内容,以及根据结果是否正确变更title的颜色
$("#dialog").css({display: "block"});
$("#dialogmask").css({display: "block"});
$("#logcontent").html(info);
if (result) {
$("#dialog_title").css({background: "#00CC00"});
} else {
$("#dialog_title").css({background: "#FF3333"});
} }
function close() {//关闭日志弹框
$("#dialog").css({display: "none"});
$("#dialogmask").css({display: "none"});
}
三、实例代码
<!DOCTYPE html>
<html lang="en">
<script src="https://cdn.bootcss.com/jquery/1.12.4/jquery.min.js"></script> <head>
<meta charset="UTF-8">
<title>测试弹框</title>
<style>
.dialogmask {
position: fixed;
top: 0px;
height: 100%;
width: 100%;
z-index: 80;
display: none; } .opacity { /*遮罩浑浊处理*/
opacity: 0.3;
filter: alpha(opacity=30);
background-color: #000;
} .box {
overflow: hidden;
position: absolute;
width: 60%;
height: 70%;
z-index: 100; /*值越大,和其他层层叠时越在上面*/
left: 20%;
top: 15%;
background-color: #fff;
border: 1px solid rgb(0, 153, 153);
} .dialogtitle {
width: 100%;
height: 30px;
line-height: 30px;
position: absolute;
font-size: 18px;
top: 0px;
background-color: lightgrey;
} .dialogcontent {
padding-top: 20px;
OVERFLOW: scroll;
height: calc(100% - 20px);
height: -webkit-calc(100% - 20px);
} .logcontent {
padding: 10px;
}
</style>
<script>
//显示弹框,并且根据结果是true或false来更改标题部分的颜色
function showlog_result(result, info) {//展示具体弹框内容,以及根据结果是否正确变更title的颜色
$("#dialog").css({display: "block"});//通过Jquery的css()更改样式
$("#dialogmask").css({display: "block"});
$("#logcontent").html(info);
if (result) {
$("#dialog_title").css({background: "#00CC00"});
} else {
$("#dialog_title").css({background: "#FF3333"});
} } function closepop() {//关闭弹框
$("#dialog").css({display: "none"});
$("#dialogmask").css({display: "none"});
}
</script>
</head>
<body>
<div>
<button onclick="showlog_result(true,'展示正确内容的弹框')">展示正确弹框</button>
<button onclick="showlog_result(false,'展示错误内容的弹框')">展示错误弹框</button>
</div>
<div id="dialogmask" class="dialogmask opacity"></div>
<div id="dialog" class="box" style="display: none">
<div id="dialog_title" class="dialogtitle">
<label style="padding-left: 10px">执行结果</label>
<label style="float: right;padding-right: 10px;" onclick="closepop()">[关闭]</label>
</div>
<div id="dialog_content" class="dialogcontent">
<div id="logcontent" class="logcontent">要显示的内容区域~</div>
</div>
</div>
</body>
</html>
html自定义弹框的更多相关文章
- vue3系列:vue3.0自定义弹框组件V3Popup|vue3.x手机端弹框组件
基于Vue3.0开发的轻量级手机端弹框组件V3Popup. 之前有分享一个vue2.x移动端弹框组件,今天给大家带来的是Vue3实现自定义弹框组件. V3Popup 基于vue3.x实现的移动端弹出框 ...
- RN code push自定义弹框
最近在弄react native的code push热更新问题.开始是用的后台默默更新配置.由于微软服务器速度问题,经常遇到用户一直在下载中问题.而用户也不知道代码需要更新才能使用新功能,影响了正常业 ...
- vue自定义弹框
vue 全局自定义简单弹框 https://www.jianshu.com/p/1307329aa09e https://www.cnblogs.com/crazycode2/p/7907905.ht ...
- swift 自定义弹框
// // ViewController.swift // animationAlert // // Created by su on 15/12/9. // Copyright © 2015 ...
- artDialog自定义弹框
弹框内容:<div class='boxy' style="display:none;" id="boxy"> //将div设置成隐藏效果 < ...
- android之自定义弹框
step1 创建窗体 final AlertDialog dialog =new Builder(this).create(); step2 获取View View viewDialog =View. ...
- svelte组件:Svelte自定义弹窗Popup组件|svelte移动端弹框组件
基于Svelte3.x自定义多功能svPopup弹出框组件(组件式+函数式) 前几天有分享一个svelte自定义tabbar+navbar组件,今天继续带来svelte自定义弹窗组件. svPopup ...
- 考拉Android统一弹框
作者:钱成杰 背景 在快速开发的背景下,经历了n个版本后的考拉Android App中已经存在了各种各样看似相同却各有差别的弹框样式.其中包括系统弹框和自定义弹框,并且在线上时常会出现IllegalA ...
- layer弹框在实际项目中的一些应用
官方介绍:layer至今仍作为layui的代表作,受众广泛并非偶然,而是这五年多的坚持,不断完善和维护.不断建设和提升社区服务,使得猿们纷纷自发传播,乃至于成为今天的Layui最强劲的源动力.目前,l ...
随机推荐
- Linux网络管理-相关笔记【自用】
ISO/OSI七层模型应用层 APDU 应用层协议数据单元 越靠近用户表示层 PPDU 表示层协议数据单元会话层 SPDU 会话协 ...
- 浮动ip cz
- 电子书 VS 纸质书
电子书, 或者网络上的博客,技术文章(最好是 一系列的, 完整的). 比起纸质书来说, 优势在于: 1 根据左部的目录快速定位 到自己想看的章节.通过PgDn PgUp 等键盘功能快速翻页 2 方便的 ...
- API / DOM
浏览器特性 当控制台报错时,IE9会停止执行JS.当打开控制台时会执行后续JS ------------------------------------------------------------ ...
- <记录> Ubuntu16.04 安装Redis以及phpredis扩展
Linux下安装Redis 1.获取redis资源 wget http://download.redis.io/releases/redis-4.0.8.tar.gz 2.解压 tar xzvf re ...
- nodejs爬虫设置动态userAgent
动态 userAgent 这是我收集到的常用的浏览器头部信息,每次爬取的时候从中随机选取一个,并使用 superAgent 设置请求头部的 User-Agent 字段就好了. userAgent.js ...
- centos7下安装python3.7
记录在2018年最后一个工作日: Linux环境坑爹得要死,环境本身有python2和python3.7两个版本:安装django2的时候,发现默认是python2:把python软连接到python ...
- addEventListener 的事件冒泡
语法 target.addEventListener(type, listener, useCapture); target 文档节点.document.window 或 XMLHttpRequest ...
- spring异常
1.The type org.springframework.core.NestedRuntimeException cannot be resolved. It is indirectly refe ...
- 多线程中的join总结笔记
join方法的原理 就是调用相应线程的wait方法进行等待操作的,假如线程1中调用了线程2的join方法,则相当于在线程1中调用了线程2的wait方法,当线程2执行完(或者到达等待时间),线程2会自动 ...