I would like to make a Celsius thermometer which, when pressed, will show the corresponding temperature in °F.
I have made a pointer and a thermometer, but I do not know what to do to get the right temperature at the press of a button.
I'm not looking to make use of any external libraries. Here's what I've tried so far:
const temperatureChange = (celsius) => {
return celsius * (9/5);
};
const getFahrenheit = (celsius) => {
return temperatureChange(celsius) + 32;
};
console.log( + getFahrenheit(15) + '°F');
html {
background: #a4b6d3;
}
.thermometer {
width: 25px;
height: 215px;
position: absolute;
top: 50%;
left: 50%;
margin-top: -107px;
margin-left: -22px;
background: #fff;
border: 10px solid #333;
border-bottom: 0;
-webkit-border-top-left-radius: 60px;
-webkit-border-top-right-radius: 60px;
-moz-border-radius-topleft: 60px;
-moz-border-radius-topright: 60px;
border-top-left-radius: 60px;
border-top-right-radius: 60px;
}
.thermometer::before {
content: " ";
position: absolute;
z-index: 0;
bottom: -56px;
left: -18px;
width: 40px;
border: 10px solid #fff;
height: 40px;
-webkit-border-radius: 30px;
-moz-border-radius: 30px;
border-radius: 30px;
}
.thermometer::after {
content: "";
display: block;
width: 60px;
height: 60px;
position: absolute;
bottom: -66px;
left: -28px;
background: red;
border: 10px solid #333;
-webkit-border-radius: 60px;
-moz-border-radius: 60px;
border-radius: 60px;
z-index: -1;
}
.thermometer-value {
font-family: Arial,sans-serif;
position: absolute;
display: block;
margin: 0;
border: 0;
width: 8px;
height: 200px;
top: 21px;
left: 8px;
overflow: hidden;
text-indent: -30px;
background: red;
}
.thermometer-cover {
position: absolute;
display: block;
width: 8px;
height: 200px;
border: 0;
left: 0;
bottom: 0%;
background: #ccc;
}
.pointer {
position:absolute;
top: 50%;
left: 50%;
margin-top: -77px;
margin-left: -22px;
width: 45px;
height: 200px;
background: none;
border:none;
}
<!DOCTYPE html>
<html lang="pl">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="stylesheet" href="style.css">
<link rel="stylesheet" href="termometr.js">
<title>Termometr</title>
</head>
<body>
<!-- thermometer -->
<div class="thermometer">
<div class="pointer">
</div>
</div>
<!-- input -->
<div class="input">
<form>
<input type="text" placeholder="°C" onfocus="this.placeholder=''" onblur="this.placeholder=''">
<input type="submit" value="Run">
</form>
</div>
</body>
</html>