File tree Expand file tree Collapse file tree 3 files changed +108
-8
lines changed Expand file tree Collapse file tree 3 files changed +108
-8
lines changed Original file line number Diff line number Diff line change 11<!DOCTYPE html>
22< html lang ="en ">
3+
34< head >
45 < meta charset ="UTF-8 ">
6+ < meta http-equiv ="X-UA-Compatible " content ="IE=edge ">
57 < meta name ="viewport " content ="width=device-width, initial-scale=1.0 ">
8+ < title > Document</ title >
69 < link rel ="stylesheet " href ="styles.css ">
7- < script src ="script.js "> </ script >
8- < title > Notes-App</ title >
910</ head >
11+
1012< body >
11-
13+ < main >
14+ < div class ="box ">
15+ < input type ="text " id ="item " autofocus placeholder ="Write something here... ">
16+ < ul id ="to-do-box ">
17+ </ ul >
18+ </ div >
19+ </ main >
20+ < script src ="https://kit.fontawesome.com/bf520e6492.js " crossorigin ="anonymous "> </ script >
21+ < script src ="script.js "> </ script >
1222</ body >
23+
1324</ html >
Original file line number Diff line number Diff line change 1+ const item = document . querySelector ( "#item" )
2+ const toDoBox = document . querySelector ( "#to-do-box" )
3+
4+ item . addEventListener (
5+ "keyup" ,
6+ function ( event ) {
7+ if ( event . key == "Enter" ) {
8+ addToDo ( this . value )
9+ this . value = ""
10+ }
11+ }
12+ )
13+
14+ const addToDo = ( item ) => {
15+ const listItem = document . createElement ( "li" ) ;
16+ listItem . innerHTML = `
17+ ${ item }
18+ <i class="fas fa-times"></i>
19+ ` ;
20+
21+ listItem . addEventListener (
22+ "click" ,
23+ function ( ) {
24+ this . classList . toggle ( "done" ) ;
25+ }
26+ )
27+ listItem . querySelector ( "i" ) . addEventListener (
28+ "click" ,
29+ function ( ) {
30+ listItem . remove ( )
31+ }
32+ )
33+ toDoBox . appendChild ( listItem )
34+ }
Original file line number Diff line number Diff line change 1- @import url ('https://fonts.googleapis.com/css2?family=Poppins:wght@200;400;600&display=swap' );
2-
3- * {
1+ @import url ('https://fonts.googleapis.com/css2?family=Open+Sans:wght@300&display=swap' );
2+ * {
3+ padding : 0 ;
4+ margin : 0 ;
45 box-sizing : border-box;
6+ font-family : 'Open Sans' , sans-serif;
7+ }
8+
9+ main {
10+ width : 100% ;
11+ height : 100vh ;
12+ display : flex;
13+ justify-content : center;
14+ align-items : center;
15+ background-color : # 3498db ;
16+ }
17+
18+ .box {
19+ width : 700px ;
20+ min-height : 500px ;
21+ background-color : white;
22+ border-radius : 5px ;
23+ padding : 15px ;
24+ }
25+
26+ # item {
27+ padding : 10px ;
28+ font-size : 20px ;
29+ width : 100% ;
30+ border : 0 ;
31+ outline : 0 ;
32+ display : block;
33+ font-weight : bold;
34+ box-shadow : 0px 0px 2px grey;
35+ }
36+
37+ # to-do-box {
38+ margin-top : 20px ;
39+ list-style : none;
40+ }
41+
42+ # to-do-box li {
43+ position : relative;
44+ background-color : # 2c3e50 ;
45+ color : white;
46+ padding : 10px ;
47+ border-radius : 2px ;
48+ padding-right : 30px ;
49+ text-align : justify;
50+ margin-top : 10px ;
51+ user-select : none;
52+ }
53+
54+ # to-do-box li i {
55+ position : absolute;
56+ right : 10px ;
57+ top : 10px ;
558}
659
7- body {
8- font-family : 'Poppins' , sans-serif;
60+ .done {
61+ text-decoration : line-through;
62+ color : black;
63+ background-color : # 95a5a6 !important ;
964}
You can’t perform that action at this time.
0 commit comments