JSFiddle - React, Tailwind, and code Playground
by Michael Prosser
HTML
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<div class="thermo">
<div class="thermometer">
<div class="thermovalues">
<span>120</span>
<span>110</span>
<span>100</span>
<span>90</span>
<span>80</span>
<span>70</span>
<span>60</span>
<span>50</span>
<span>40</span>
<span>30</span>
<span>20</span>
<span>10</span>
<span>0</span>
<span>-10</span>
<span>-20</span>
<span>-30</span>
<span>-40</span>
</div>
<div class="thermobar" data-degrees="96">
<div></div>
</div>
</div>
</div>
CSS
.thermo{
position: fixed;
left: 0px;
top: 0px;
bottom: 0px;
width: 500px;
background-color: #000;
}
.thermo > .thermometer{
width: 200px;
height: 400px;
font-size: 9px;
color: #fff;
font-family: "helvetica", serif;
position: absolute;
display: block;
left: 50%;
top: 50%;
transform: translateX(-50%) translateY(-50%);
}
.thermo > .thermometer > .thermovalues{
position: absolute;
left: 50%;
margin-left: -40px;
top: 10px;
}
.thermo > .thermometer > .thermovalues span{
display: block;
text-align: right;
margin: 0px;
line-height: 20px;
}
.thermo > .thermometer > .thermovalues span:after{
display: inline;
content: "-";
}
.thermo > .thermometer > .thermobar{
border: solid 1px #fff;
height: 340px;
top: 10px;
position: absolute;
left: 50%;
transform: translateX(-50%);
width: 14px;
border-bottom: none;
-webkit-border-top-left-radius: 7px;
-webkit-border-top-right-radius: 7px;
-moz-border-radius-topleft: 7px;
-moz-border-radius-topright: 7px;
border-top-left-radius: 7px;
border-top-right-radius: 7px;
background-color: #333;
}
.thermo > .thermometer > .thermobar:before{
display: block;
-webkit-border-radius: 50%;
-moz-border-radius: 50%;
border-radius: 50%;
border: solid 1px #fff;
height: 30px;
bottom: -30px;
position: absolute;
left: 50%;
transform: translateX(-50%);
width: 30px;
content: attr(data-degrees);
background-color: #1f66b1;
line-height: 30px;
text-align: center;
font-weight: bold;
font-size: 17px;
}
.thermo > .thermometer > .thermobar:after{
display: block;
height: 30px;
bottom: -22px;
position: absolute;
left: 50%;
margin-left: 20px;
transform: translateX(-50%);
width: 30px;
content: "°";
line-height: 30px;
text-align: center;
font-weight: bold;
font-size: 17px;
}
.thermo > .thermometer > .thermobar > div{
position: absolute;
bottom: 0px;
left: 0px;
right: 0px;
height: 330px;
background-color: #1f66b1;
...
JavaScript
function setThermometer(v){
var offset = 10;
var p = (v * 2) + 90;
$('.thermometer > .thermobar > div').css('height','' + p + 'px')
}
setThermometer(120);
setTimeout(function(){
setThermometer(80);
setTimeout(function(){
setThermometer(90);
},5000);
},5000);