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设置DNS server
查看: cat /etc/resolv.conf 修改: vim /etc/resolv.conf
- OpenGL中摄像机矩阵的计算原理
熟悉OpenGL|ES的朋友,可能会经常设置摄像机的view矩阵,iOS中相对较好,已经封装了方向,只需要设置摄像机位置,目标点位置以及UP向量即可.下面先介绍下摄像机view矩阵的计算原理.此处假设 ...
- linux的可中断sleep_on函数分析
void interruptible_sleep_on (struct task_struct **p)// **p是个全局变量 { struct task_struct *tmp; if (!p)# ...
- 网站优化--减少HTTP请求
发送HTTP请求需要经过几个过程 域名解析--TCP连接--发送请求--等待--下载资源--解析时间 这其中需要花费一定时间,因此,尽可能的需要减少网站的HTTP请求,方法有以下几种: 1 . css ...
- element(vue.js)+django 整合
近期开始接触Python,从web开发入门.尝试Django与vue整合,大概分3个阶段: 1.基于Django开发web后端 2.基于element开发好前端 3.前后端整合 参考:https:// ...
- golang 操作redis 错误:failed redigo: unexpected type for String, got type int64
报错的代码: isExist,err := redis.String(conn.Do("EXISTS", key)) 这个操作返回的应该是bool类型,所有改成 isExist,e ...
- 浅谈 foreach 的原理
package com.shenzhou; import java.util.ArrayList; import java.util.Iterator; import java.util.List; ...
- Dev的TextEdit控件IP地址的Mask设置
1. 添加TextEdit控件. 2. 选中TextEdit控件,查看控件属性. 3. 展开Properties属性项,找到Mask属性项. 4. 设置Mask属性项的EditMask属性值为:(25 ...
- 如何使用JDBC查询指定的记录
//连接数据库 public class JdbcDao { private Connection conn=null; private String strSql=null; publi ...
- monkey压力测试
压力测试: monkey -p com.qihu360.mobilesafe -v -p 后面跟包名 : -v 后面跟次数: 通过观察log日志,查看应用中出现的问题. =============== ...