博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
html5+css3+javascript 自定义弹出窗口
阅读量:5834 次
发布时间:2019-06-18

本文共 3494 字,大约阅读时间需要 11 分钟。

效果图:

源码:

  1.demo.jsp

1 <%@ page contentType="text/html;charset=UTF-8" language="java" %> 2  3  4     自定义弹出窗口 5      6     23     35 36 37     38 39 

  2.myLayer.js

1 /** 2  * Created by zhuwenqi on 2017/6/16. 3  */ 4 /** 5  * @param options 弹窗基本配置信息 6  * @constructor 构造方法 7  */ 8 function MyLayer(options) { 9     this.options = options ;10 }11 /**12  * 打开弹窗13  */14 MyLayer.prototype.openLayer = function () {15     var background_layer = document.createElement("div");16     background_layer.style.display = "none";17     background_layer.style.position = "absolute";18     background_layer.style.top =  "0px";19     background_layer.style.left = "0px";20     background_layer.style.width = "100%";21     background_layer.style.height = "100%";22     background_layer.style.backgroundColor = "gray";23     background_layer.style.zIndex = "1001";24     background_layer.style.opacity = "0.8" ;25     var open_layer = document.createElement("div");26     open_layer.style.display = "none";27     open_layer.style.position = "absolute";28     open_layer.style.top = this.options.top === undefined ? "10%" : this.options.top;29     open_layer.style.left = this.options.left === undefined ? "10%" :this.options.left;30     open_layer.style.width = this.options.width === undefined ? "80%" : this.options.width;31     open_layer.style.height = this.options.height === undefined ? "80%" : this.options.height;32     open_layer.style.border = "1px solid lightblue";33     open_layer.style.borderRadius = "15px" ;34     open_layer.style.boxShadow = "4px 4px 10px #171414";35     open_layer.style.backgroundColor = "white";36     open_layer.style.zIndex = "1002";37     open_layer.style.overflow = "auto";38     var div_toolBar = document.createElement("div");39     div_toolBar.style.textAlign = "right";40     div_toolBar.style.paddingTop = "10px" ;41     div_toolBar.style.backgroundColor = "aliceblue";42     div_toolBar.style.height = "40px";43     var span_title = document.createElement("span");44     span_title.style.fontSize = "18px";45     span_title.style.color = "blue" ;46     span_title.style.float = "left";47     span_title.style.marginLeft = "20px";48     var span_title_content = document.createTextNode(this.options.title === undefined ? "" : this.options.title);49     span_title.appendChild(span_title_content);50     div_toolBar.appendChild(span_title);51     var span_close = document.createElement("span");52     span_close.style.fontSize = "16px";53     span_close.style.color = "blue" ;54     span_close.style.cursor = "pointer";55     span_close.style.marginRight = "20px";56     span_close.onclick = function () {57         open_layer.style.display = "none";58         background_layer.style.display = "none";59     };60     var span_close_content = document.createTextNode("关闭");61     span_close.appendChild(span_close_content);62     div_toolBar.appendChild(span_close);63     open_layer.appendChild(div_toolBar);64     var div_content = document.createElement("div");65     div_content.style.textAlign = "center";66     var content_area = document.createTextNode(this.options.content === undefined ? "" : this.options.content);67     div_content.appendChild(content_area);68     open_layer.appendChild(div_content);69     document.body.appendChild(open_layer);70     document.body.appendChild(background_layer);71     open_layer.style.display = "block" ;72     background_layer.style.display = "block";73 };

 

转载于:https://www.cnblogs.com/zhuwenqi2016/p/7058037.html

你可能感兴趣的文章
[转]linux创建链接文件的两种方法
查看>>
python ipaddress模块使用
查看>>
文件权限
查看>>
busybox里的僵尸进程为何那么多
查看>>
python debug
查看>>
java 连接数据库之一个完整的函数
查看>>
mysql脚本
查看>>
OllyDBG 入门系列教学--让你瞬间成为破解高手
查看>>
Dubbo点滴(2)之集群容错
查看>>
检测不到兼容的键盘驱动程序
查看>>
listbox用法
查看>>
冲刺第九天 1.10 THU
查看>>
传值方式:ajax技术和普通传值方式
查看>>
Linux-网络连接-(VMware与CentOS)
查看>>
寻找链表相交节点
查看>>
AS3——禁止swf缩放
查看>>
linq 学习笔记之 Linq基本子句
查看>>
[Js]布局转换
查看>>
Hot Bath
查看>>
国内常用NTP服务器地址及
查看>>