Skip to content

Commit f9449ec

Browse files
committed
Code 2 - Class 14 / 1
1 parent c304f23 commit f9449ec

3 files changed

Lines changed: 89 additions & 0 deletions

File tree

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
* {
2+
padding: 0;
3+
margin: 0;
4+
box-sizing: border-box;
5+
}
6+
7+
body {
8+
margin: 20px;
9+
}
10+
.modal {
11+
position: relative;
12+
display: flex;
13+
justify-content: center;
14+
align-items: center;
15+
position: fixed;
16+
top: 50%;
17+
left: 50%;
18+
transform: translate(-50%, -50%);
19+
width: 400px;
20+
height: 200px;
21+
background-color: #ddd;
22+
border-radius: 8px;
23+
opacity: 0;
24+
visibility: hidden;
25+
display: none;
26+
transition: all 0.5s;
27+
}
28+
29+
#close-modal {
30+
background-color: transparent;
31+
border: none;
32+
cursor: pointer;
33+
position: absolute;
34+
border-radius: 16px;
35+
transition: all 0.4s;
36+
padding: 4px;
37+
top: 4%;
38+
right: 2%;
39+
}
40+
41+
#close-modal:hover {
42+
background-color: rgba(255, 0, 0, 0.262);
43+
}
44+
45+
.show {
46+
opacity: 1;
47+
visibility: visible;
48+
display: block;
49+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta
6+
name="viewport"
7+
content="width=device-width, initial-scale=1.0"
8+
/>
9+
<link rel="stylesheet" href="css/styele.css">
10+
<title>Document</title>
11+
</head>
12+
<body>
13+
<button id="open-modal">Open Modal</button>
14+
15+
<div class="modal">
16+
<p>Lorem ipsum dolor sit.</p>
17+
<button id="close-modal"></button>
18+
</div>
19+
20+
<script src="js/script.js"></script>
21+
</body>
22+
</html>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
"use strict"
2+
3+
const openBtn = document.querySelector("#open-modal")
4+
const closeBtn = document.querySelector("#close-modal")
5+
const modalEl = document.querySelector(".modal")
6+
7+
8+
openBtn.addEventListener("click",()=>{
9+
modalEl.classList.add("show")
10+
})
11+
12+
closeBtn.addEventListener("click",()=>{
13+
modalEl.classList.remove("show")
14+
})
15+
16+
setTimeout(()=>{
17+
modalEl.classList.add("show")
18+
}, 5000)

0 commit comments

Comments
 (0)