Repository navigation
Expand file tree
/
Copy pathmodal.html
More file actions
115 lines (74 loc) · 3.19 KB
/
Copy pathmodal.html
File metadata and controls
115 lines (74 loc) · 3.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="shortcut icon" href="assets/imgs/favicon.png" type="image/x-icon">
<link rel="stylesheet" href="assets/css/prism.css">
<link rel="stylesheet" href="assets/css/uncaught.css">
<link rel="stylesheet" href="assets/css/custom.css">
<link rel="stylesheet" href="assets/css/main.css">
<title>Modal - Uncaught.css</title>
</head>
<body>
<div class="container">
<h5 class="h">Modal (how it works)</h5>
<ul>
<li>Modals are built with HTML, CSS, and JavaScript. They’re positioned (fixed) over everything else in the document and remove scroll from the <strong>body</strong> so that modal content scrolls instead.</li>
<br>
<li>Clicking the transparent background will automatically close the modal.</li>
</ul>
<br>
<div class="modal">
<div class="modal-window">
<div class="modal-content">
<p>Another crazy center-embedded sentence. Can you figure it out? Start with "anyone who feels X is likely to agree." Then go to "anyone who feels if X then Y is likely to agree." Then fill out the X and Y. You might need a pencil and paper.</p>
<button class="btn dark">I concur</button>
<button class="btn primary"> <i class="fa fa-twitter"></i> let's tweet it</button>
</div>
</div>
</div>
<button class="btn dark modal-trigger">Click me to reveal modal</button>
<script type="text/plain" class="language-markup">
<div class="modal">
<div class="modal-window">
<div class="modal-content">
<p>Another crazy center-embedded sentence. Can you figure it out? Start with "anyone who feels X
is likely to agree." Then go to "anyone who feels
if X then Y is likely to agree." Then fill out the
X and Y. You might need a pencil and paper.</p>
<button class="btn dark">I concur</button> <button class="btn primary">let's tweet it</button>
</div>
</div>
</div>
<!--Modal trigger-->
<button class="btn dark modal-trigger">Click me to reveal modal</button>
</script>
<h5 class="h">The JavaScript</h5>
<pre>
<code class="language-javascript">
const modalTrigger = document.querySelector('.modal-trigger');
const modal = document.querySelector('.modal');
//open modal
modalTrigger.addEventListener('click', () => {
modal.classList.add('modal-is-active')
})
window.addEventListener('click', closeModal); //close modal
//close modal function
function closeModal(e){
if(e.target == modal){
modal.classList.remove('modal-is-active')
}
}
</code>
</pre>
</div>
<br>
<footer id="footer">
</footer>
<script src="js/prism.js"></script>
<script src="js/docs.js"></script>
<script src="js/main.js"></script>
</body>
</html>