|
@@ -0,0 +1,92 @@
|
|
|
+<!DOCTYPE html>
|
|
|
+<html lang="en">
|
|
|
+
|
|
|
+<head>
|
|
|
+ <meta charset="UTF-8">
|
|
|
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
|
+ <title>Document</title>
|
|
|
+ <style>
|
|
|
+ * {
|
|
|
+ margin: 0;
|
|
|
+ padding: 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ #box {
|
|
|
+ width: 100vw;
|
|
|
+ position: relative;
|
|
|
+ }
|
|
|
+
|
|
|
+ #under {
|
|
|
+ width: 90%;
|
|
|
+ height: 500px;
|
|
|
+ background: rgba(0, 0, 0, .1);
|
|
|
+ margin: 10px auto;
|
|
|
+ text-align: center;
|
|
|
+ line-height: 500px;
|
|
|
+ font-size: 25px;
|
|
|
+ }
|
|
|
+
|
|
|
+ #vase {
|
|
|
+ width: 80%;
|
|
|
+ height: 300px;
|
|
|
+ background: #fff;
|
|
|
+ position: absolute;
|
|
|
+ top: 100px;
|
|
|
+ left: 37px;
|
|
|
+ z-index: 9;
|
|
|
+ }
|
|
|
+ #close {
|
|
|
+ width: 100px;
|
|
|
+ height: 30px;
|
|
|
+ text-align: center;
|
|
|
+ line-height: 30px;
|
|
|
+ background: #00f;
|
|
|
+ color: #fff;
|
|
|
+ position: absolute;
|
|
|
+ top: 50%;
|
|
|
+ left: 50%;
|
|
|
+ margin-top: -15px;
|
|
|
+ margin-left: -50px;
|
|
|
+ }
|
|
|
+
|
|
|
+ #dialog {
|
|
|
+ width: 100%;
|
|
|
+ height: 100vh;
|
|
|
+ position: fixed;
|
|
|
+ top: 0;
|
|
|
+ left: 0;
|
|
|
+ background: rgba(0,0,0,.5);
|
|
|
+ }
|
|
|
+ </style>
|
|
|
+</head>
|
|
|
+
|
|
|
+<body>
|
|
|
+ <div id="box">
|
|
|
+ <div id="under">底层元素</div>
|
|
|
+ <div id="vase">
|
|
|
+ <div id="tit">弹出层</div>
|
|
|
+ <div id="close">关闭</div>
|
|
|
+ </div>
|
|
|
+ <div id="dialog"></div>
|
|
|
+ </div>
|
|
|
+ <script>
|
|
|
+ /**
|
|
|
+ * 点透事件:
|
|
|
+ * 1.两层元素叠加
|
|
|
+ * 2.第一层使用touch事件
|
|
|
+ * 3.第二层使用click事件/a标签
|
|
|
+ */
|
|
|
+ var close = document.getElementById("close");
|
|
|
+ var under = document.getElementById("under");
|
|
|
+ close.ontouchstart = function(event) {
|
|
|
+ event.preventDefault();
|
|
|
+ document.getElementById("vase").style.display = 'none';
|
|
|
+ document.getElementById("dialog").style.display = 'none';
|
|
|
+ }
|
|
|
+ under.onclick = function() {
|
|
|
+ alert("弹出")
|
|
|
+ }
|
|
|
+ </script>
|
|
|
+</body>
|
|
|
+
|
|
|
+</html>
|