File tree Expand file tree Collapse file tree 2 files changed +72
-2
lines changed
Expand file tree Collapse file tree 2 files changed +72
-2
lines changed Original file line number Diff line number Diff line change @@ -19,13 +19,35 @@ <h1>JavaScript Basics</h1>
1919 < h3 id ="smile "> </ h3 >
2020 </ div >
2121 </ section >
22+ < section class ="section ">
23+ < h3 class ="sum-title "> Sum two numbers</ h3 >
24+ < div class ="section-content ">
25+ < div class ="sum-content ">
26+ < label > Type number one</ label >
27+ < input type ="number " id ="num-1 ">
28+ </ div >
29+ < div class ="sum-content ">
30+ < label > Type number two</ label >
31+ < input type ="number " id ="num-2 ">
32+ </ div >
33+ </ div >
34+ < button id ="result-button "> Sum +</ button >
35+ < h3 id ="result "> </ h3 >
36+ </ section >
2237 </ main >
2338
2439 < script >
2540 document . querySelector ( '#smile-button' ) . addEventListener ( 'click' , function ( ) {
2641 let name = prompt ( 'Type your name!' ) ;
27- document . getElementById ( 'smile' ) . innerHTML = `Welcome ${ name } , nice to meet you! 😊` ;
42+ document . getElementById ( 'smile' ) . innerHTML = `Welcome <span> ${ name } </span> , nice to meet you! 😊` ;
2843 } ) ;
44+
45+ document . querySelector ( '#result-button' ) . addEventListener ( 'click' , function ( ) {
46+ let num1 = document . getElementById ( 'num-1' ) . value ;
47+ let num2 = document . getElementById ( 'num-2' ) . value ;
48+ let result = parseInt ( num1 ) + parseInt ( num2 ) ;
49+ document . getElementById ( 'result' ) . innerHTML = `Rresult is: <span>${ result } </span>` ;
50+ } )
2951 </ script >
3052
3153</ body >
Original file line number Diff line number Diff line change 88body {
99 height : 100% ;
1010 font-family : Arial, sans-serif;
11+ color : darkslategray;
1112}
1213
1314body {
@@ -41,17 +42,41 @@ section {
4142 padding : 1.5rem ;
4243 background-color : # f9f9f9 ;
4344 overflow-y : auto;
45+ display : flex;
46+ flex-direction : column;
47+ justify-content : center;
48+ text-align : center;
4449}
4550
4651.section {
4752 margin : 24px auto;
4853 max-width : 400px ;
54+ display : flex;
55+ flex-direction : column;
56+ }
57+
58+ .section-content {
59+ display : grid;
60+ grid-template-columns : 1fr 1fr ;
61+ margin-bottom : 1rem ;
62+ gap : 2rem ;
4963}
5064
5165.smile-content {
5266 text-align : center;
5367}
5468
69+ .sum-title {
70+ color : chocolate;
71+ font-size : 1.5rem ;
72+ margin-bottom : 2rem ;
73+ }
74+
75+ span {
76+ color : chocolate;
77+ font-size : 1.5rem ;
78+ }
79+
5580button {
5681 background-color : blueviolet;
5782 color : bisque;
@@ -61,4 +86,27 @@ button {
6186 font-size : 1rem ;
6287 cursor : pointer;
6388 margin : 1rem ;
64- }
89+ max-width : fit-content;
90+ align-self : center;
91+ }
92+
93+ label {
94+ display : block;
95+ margin-bottom : 0.7rem ;
96+ font-weight : 600 ;
97+ }
98+
99+ input {
100+ width : 100% ;
101+ padding : 0.8rem 1rem ;
102+ border : 1px solid gray;
103+ border-radius : 5px ;
104+ font-family : inherit;
105+ font-size : 1rem ;
106+ }
107+
108+ input : focus {
109+ outline : none;
110+ border-color : blueviolet;
111+ box-shadow : 0 0 5px rgba (138 , 43 , 226 , 0.5 );
112+ }
You can’t perform that action at this time.
0 commit comments