Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
sugalipravallikabai authored May 2, 2023
1 parent b84186f commit 12e670f
Show file tree
Hide file tree
Showing 4 changed files with 131 additions and 0 deletions.
32 changes: 32 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="style.css">
<title>Temperature converter</title>
</head>

<body>
<div class="container">
<form id="calcTemp" onsubmit="calculateTemp(); return false">
<label for="temp">Enter the temperature to convert</label>
<br>
<input type="number" name="temp" id="temp" value="0">
<select name="temp_diff" id="temp_diff">
<option value="cel">&#176;Celsius</option>
<option value="fah">&#176;Fahrenheit</option>
</select>
<br>
<input type="submit" name="temp" id="submit">
<br>
<span id="result"></span>
</form>
</div>

<script src="script.js"></script>
</body>

</html>
25 changes: 25 additions & 0 deletions script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
const calculateTemp = () => {
const inputTemp = document.getElementById('temp').value;

const tempSelected = document.getElementById('temp_diff');
const valueTemp = temp_diff.options[tempSelected.selectedIndex].value;

// Celsius to Fahrenheit
const celToFah = (cel) => {
let fahrenheit = ((cel * 9 / 5) + 32).toFixed(1);
return fahrenheit;
}

// Fahrenheit to Celsius
const fahToCel = (fah) => {
let celsius = ((fah - 32) * 5 / 9).toFixed(1);
return celsius;
}

if (valueTemp == 'cel') {
document.getElementById("result").innerHTML = celToFah(inputTemp) + "&#176; Fahrenheit";
}
else {
document.getElementById("result").innerHTML = fahToCel(inputTemp) + "&#176; Celsius";
}
}
Binary file added shutterstock_144222931jpg.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
74 changes: 74 additions & 0 deletions style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
* {
box-sizing: border-box;
padding: 0;
margin: 0;
font-family: 'Poppins', sans-serif;
}
body{
background-image: url(shutterstock_144222931jpg.jpg);
image-rendering: none;
image-resolution: none;
background-size: 1500px;

}
.container {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
text-align: center;
}

#calcTemp {
padding: 29px 67px;
min-height: 290px;
background-color: #e48e4c;
box-shadow: rgba(0, 0, 0, 0.12) 0px 1px 3px, rgba(0, 0, 0, 0.24) 0px 1px 2px;
}

label {
font-size: 30px;
line-height: 78px;
}

#temp {
width: 110px;
height: 34px;
border-radius: 5px;
margin: 12px;
padding: 8px;
font-size: 20px;
font-weight: 500;
border: none;
outline: none;
}

#temp_diff {
width: 120px;
height: 34px;
border-radius: 5px;
margin: 12px;
font-size: 18px;
font-weight: 500;
border: none;
outline: none;
}

#submit {
width: 100px;
border-radius: 5px;
margin: 30px 0 20px 0;
font-size: 18px;
background-color: rgb(218 229 220);
padding: 5px;
transition: all 0.5s ease;
}

#submit:hover{
background-color: antiquewhite;
cursor: pointer;
}

#result{
font-size: 27px;
}

0 comments on commit 12e670f

Please sign in to comment.