File tree Expand file tree Collapse file tree 4 files changed +52
-54
lines changed Expand file tree Collapse file tree 4 files changed +52
-54
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change 99 </ head >
1010 < body >
1111 < div class ="container ">
12- < div class ="heading "> Temperature Convertor</ div >
13- < div class ="box ">
12+ < h1 class ="heading "> Temperature Convertor</ h1 >
13+ < div class ="temp-container ">
1414 < label for ="celsius "> Celsius:</ label >
1515 < input
16+ onchange ="computeTemp(event) "
1617 type ="number "
1718 name ="celsius "
1819 id ="celsius "
1920 placeholder ="Enter Temperature "
20- class ="input_box "
21- onchange ="computeTemp(event) "
21+ class ="input "
2222 />
2323 </ div >
24- < div class ="box ">
24+ < div class ="temp-container ">
2525 < label for ="fahrenheit "> Fahrenheit:</ label >
2626 < input
27+ onchange ="computeTemp(event) "
2728 type ="number "
2829 name ="fahrenheit "
2930 id ="fahrenheit "
3031 placeholder ="Enter Temperature "
31- class ="input_box "
32- onchange ="computeTemp(event) "
32+ class ="input "
3333 />
3434 </ div >
35- < div class ="box ">
35+ < div class ="temp-container ">
3636 < label for ="kelvin "> Kelvin:</ label >
3737 < input
38+ onchange ="computeTemp(event) "
3839 type ="number "
3940 name ="kelvin "
4041 id ="kelvin "
4142 placeholder ="Enter Temperature "
42- class ="input_box "
43- onchange ="computeTemp(event) "
43+ class ="input "
4444 />
4545 </ div >
4646 </ div >
47-
4847 < script src ="index.js "> </ script >
4948 </ body >
5049</ html >
Original file line number Diff line number Diff line change 1+ const celsiusEl = document . getElementById ( "celsius" ) ;
2+ const fahrenheitEl = document . getElementById ( "fahrenheit" ) ;
3+ const kelvinEl = document . getElementById ( "kelvin" ) ;
4+
5+ function computeTemp ( event ) {
6+ const currentValue = + event . target . value ;
7+
8+ switch ( event . target . name ) {
9+ case "celsius" :
10+ kelvinEl . value = ( currentValue + 273.32 ) . toFixed ( 2 ) ;
11+ fahrenheitEl . value = ( currentValue * 1.8 + 32 ) . toFixed ( 2 ) ;
12+ break ;
13+ case "fahrenheit" :
14+ celsiusEl . value = ( ( currentValue - 32 ) / 1.8 ) . toFixed ( 2 ) ;
15+ kelvinEl . value = ( ( currentValue - 32 ) / 1.8 + 273.32 ) . toFixed ( 2 ) ;
16+ break ;
17+ case "kelvin" :
18+ celsiusEl . value = ( currentValue - 273.32 ) . toFixed ( 2 ) ;
19+ fahrenheitEl . value = ( ( currentValue - 273.32 ) * 1.8 + 32 ) . toFixed ( 2 ) ;
20+ break ;
21+ default :
22+ break ;
23+ }
24+ }
Original file line number Diff line number Diff line change 66 justify-content : center;
77 align-items : center;
88 font-family : monospace;
9- font-size : 1.25rem ;
109 color : darkcyan;
1110}
1211
13- .heading {
14- height : 58px ;
15- line-height : 58px ;
16- width : 100% ;
17- font-size : 2rem ;
18- font-weight : bolder;
19- text-align : center;
20- border-radius : 10px ;
21- padding : 0 15px ;
22- margin-bottom : 28px ;
23- }
2412.container {
13+ background : rgba (255 , 255 , 255 , 0.3 );
14+ padding : 20px ;
15+ box-shadow : 0 4px 10px rgba (0 , 0 , 0 , 0.3 );
16+ border-radius : 10px ;
2517 width : 85% ;
2618 max-width : 450px ;
2719 min-width : 350px ;
28- padding : 20px ;
2920 display : flex;
3021 flex-direction : column;
3122 align-items : center;
32- border-radius : 10px ;
33- background : rgba (255 , 255 , 255 , 0.3 );
34- box-shadow : 0 4px 10px rgba (0 , 0 , 0 , 0.3 );
3523}
36- .box {
24+
25+ .heading {
26+ font-size : 32px ;
27+ }
28+
29+ .temp-container {
3730 width : 100% ;
3831 padding : 15px ;
3932 font-weight : bold;
33+ font-size : 18px ;
4034}
41- .input_box {
42- width : 14rem ;
35+
36+ .input {
37+ width : 220px ;
4338 font-family : monospace;
4439 padding : 5px ;
4540 float : right;
4641 outline : none;
4742 background : rgba (255 , 255 , 255 , 0.3 );
4843 border-color : rgba (255 , 255 , 255 , 0.5 );
4944 color : darkgreen;
50- font-size : 1.25 rem ;
45+ font-size : 18 px ;
5146}
5247
53- .input_box ::placeholder {
54- color : darkgray;
48+
49+ .input ::placeholder {
50+ color : darkgray;
5551}
You can’t perform that action at this time.
0 commit comments