File tree Expand file tree Collapse file tree
Block Chain Collage Code 2/14/1 Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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+ }
Original file line number Diff line number Diff line change 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 >
Original file line number Diff line number Diff line change 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 )
You can’t perform that action at this time.
0 commit comments