From e69251111f589e1c8140f8f74b3a9b78ae01a804 Mon Sep 17 00:00:00 2001 From: Chei <107986749+prchlmrie@users.noreply.github.com> Date: Fri, 2 Aug 2024 15:01:37 +0800 Subject: [PATCH] Add files via upload --- index.html | 28 ++++++++++++++++++++++++++++ index.js | 24 ++++++++++++++++++++++++ style.css | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 106 insertions(+) create mode 100644 index.html create mode 100644 index.js create mode 100644 style.css diff --git a/index.html b/index.html new file mode 100644 index 0000000..34bb9fb --- /dev/null +++ b/index.html @@ -0,0 +1,28 @@ + + + + + + Temperature Conversion + + + + +
+

Temperature Conversion:

+ +
+ + +
+ + +
+ +

Select a unit

+ +
+ + + + \ No newline at end of file diff --git a/index.js b/index.js new file mode 100644 index 0000000..02f5b8a --- /dev/null +++ b/index.js @@ -0,0 +1,24 @@ +const textNum = document.getElementById(`textNum`); +const toFahrenheit = document.getElementById(`toFahrenheit`); +const toCelcius = document.getElementById(`toCelcius`); +const result = document.getElementById(`result`); + +let temp; + +function convert(){ + + if(toFahrenheit.checked){ + temp = Number(textNum.value); + temp = temp * 9 / 5 + 32; + result.textContent = temp.toFixed(1) + "°F"; + } + else if(toCelcius.checked){ + temp = Number(textNum.value); + temp = (temp - 32) * (5/9); + result.textContent = temp.toFixed(1) + "°C"; + } + else{ + result.textContent = `Select a unit`; + } + +} \ No newline at end of file diff --git a/style.css b/style.css new file mode 100644 index 0000000..cec6425 --- /dev/null +++ b/style.css @@ -0,0 +1,54 @@ +body{ + font-family: monospace; + background-color: antiquewhite; +} + +h1{ + font-weight: bold; +} + +form{ + text-align: center; + max-width: 300px; + margin: auto; + padding: 25px; + background-color:rgb(216, 215, 228); + box-shadow: 5px 5px 15px black; + border-radius: 10px; +} + +label{ + font-size: 20px; + font-weight: bold; +} + +#textNum{ + width: 50%; + text-align: center; + font-size: 2em; + border: 2px solid black; + border-radius: 4px; + margin-bottom: 15px; +} + +button{ + margin-top: 15px; + color: white; + background-color: rgb(255, 10, 10); + font-size: 15px; + cursor: pointer; + border-radius: 5px; + padding: 5px, 10px; +} + +button:hover{ + background-color: rgb(207, 37, 37); + color: black; +} + +#result{ + font-weight: bold; + font-size: 20px; + font-style: italic; + color: blue; +} \ No newline at end of file