File tree 3 files changed +107
-0
lines changed
3 files changed +107
-0
lines changed Original file line number Diff line number Diff line change
1
+ <!DOCTYPE html>
2
+ < html lang ="en ">
3
+
4
+ < head >
5
+ < meta charset ="UTF-8 ">
6
+ < meta http-equiv ="X-UA-Compatible " content ="IE=edge ">
7
+ < meta name ="viewport " content ="width=device-width, initial-scale=1.0 ">
8
+ < title > Temperature Converter</ title >
9
+ < link rel ="stylesheet " href ="style.css ">
10
+ </ head >
11
+
12
+ < body >
13
+ < h1 > Temperature Converter</ h1 >
14
+
15
+ < div id ="container ">
16
+
17
+ <!-- CELSIUS -->
18
+ < div class ="input-div ">
19
+ < label > Celsius
20
+ < input type ="number " id ="cel " class ="entry " value ="0 ">
21
+ </ label >
22
+ </ div >
23
+
24
+ <!-- FAHRENHEIT -->
25
+ < div class ="input-div ">
26
+ < label > Fahrenheit
27
+ < input type ="number " id ="fah " class ="entry " value ="32 ">
28
+ </ label >
29
+ </ div >
30
+ </ div >
31
+
32
+ <!-- added external js file -->
33
+ < script src ="script.js "> </ script >
34
+ </ body >
35
+
36
+ </ html >
Original file line number Diff line number Diff line change
1
+ let cel = document . getElementById ( 'cel' ) ;
2
+ let fah = document . getElementById ( 'fah' ) ;
3
+
4
+
5
+ //===== CONVERTING CELSIUS TO FAHRENHEIT
6
+ cel . addEventListener ( 'input' , function ( ) {
7
+ let f = ( this . value * 9 / 5 ) + 32 ;
8
+ if ( ! Number . isInteger ( f ) ) {
9
+ f = Number ( f . toFixed ( 3 ) ) ;
10
+ }
11
+ fah . value = f ;
12
+ } ) ;
13
+
14
+ //===== CONVERTING FAHRENHEIT TO CELSIUS
15
+ fah . addEventListener ( 'input' , function ( ) {
16
+ let c = ( this . value - 32 ) * 5 / 9 ;
17
+ if ( ! Number . isInteger ( c ) ) {
18
+ c = Number ( c . toFixed ( 3 ) ) ;
19
+ }
20
+ cel . value = c
21
+ } ) ;
Original file line number Diff line number Diff line change
1
+ @import url ('https://fonts.googleapis.com/css2?family=Red+Hat+Display&display=swap' );
2
+
3
+ /* CSS RESET */
4
+ * , * ::before , * ::after {
5
+ box-sizing : border-box;
6
+ margin : 0 ;
7
+ }
8
+
9
+ /* ====== GENERAL TAGS ====== */
10
+ body {
11
+ padding : 8% 10% ;
12
+ font-family : 'Red Hat Display' , sans-serif;
13
+ }
14
+ h1 {
15
+ text-align : center;
16
+ }
17
+
18
+ /* ======= CONTAINER ======= */
19
+ # container {
20
+ margin : 2rem auto;
21
+ padding : 2rem ;
22
+ background-color : rgb (133 , 231 , 133 );
23
+ width : 80% ;
24
+ display : flex;
25
+ justify-content : space-around;
26
+ text-align : center;
27
+ }
28
+ @media (max-width : 900px ){
29
+ # container {
30
+ flex-direction : column;
31
+ }
32
+ .input-div {
33
+ margin : 20px auto;
34
+ }
35
+ }
36
+
37
+ /* ====== INPUT SECTION ====== */
38
+ label {
39
+ font-size : 1.5rem ;
40
+ }
41
+ .entry {
42
+ display : block;
43
+ font-size : 1.8rem ;
44
+ font-weight : bold;
45
+ width : 90% ;
46
+ min-width : 100px ;
47
+ margin : auto;
48
+ text-align : center;
49
+ padding : 0.4em 0.6em ;
50
+ }
You can’t perform that action at this time.
0 commit comments