diff --git a/my code/10-dad-jokes/index.html b/my code/10-dad-jokes/index.html new file mode 100644 index 0000000..7739fb8 --- /dev/null +++ b/my code/10-dad-jokes/index.html @@ -0,0 +1,25 @@ + + + + + + + + 10 dad jokes + + + + + + +
+ Try not to laugh + Loading... + + +
+ + + + + \ No newline at end of file diff --git a/my code/10-dad-jokes/script.js b/my code/10-dad-jokes/script.js new file mode 100644 index 0000000..e6d9b88 --- /dev/null +++ b/my code/10-dad-jokes/script.js @@ -0,0 +1,21 @@ +const button = document.getElementById("btn"); +const span = document.getElementById("joke"); + +const url = "https://icanhazdadjoke.com"; +const fetchJoke = async () => { + const config = { + headers: { + Accept: "application/json", + }, + }; + + const resp = await fetch(url, config); + const data = await resp.json(); + + let joke = ""; + + joke = data.joke; + span.innerHTML = joke; +}; + +fetchJoke(); diff --git a/my code/10-dad-jokes/style.css b/my code/10-dad-jokes/style.css new file mode 100644 index 0000000..dbbdc3d --- /dev/null +++ b/my code/10-dad-jokes/style.css @@ -0,0 +1,59 @@ +* { + margin: 0; + padding: 0; +} + +body { + background-color: darkorchid; + font-family: sans-serif; + display: flex; + justify-content: center; + align-items: center; + height: 100vh; +} + +.container { + width: 600px; + padding: 60px; + background-color: #fff; + border-radius: 10px; + box-shadow: 0 5px 10px rgba(0, 0, 0, 0.6); + display: grid; + grid-gap: 80px; + align-items: center; +} + +.container > span, +.container > button { + margin: auto; +} + +.head { + font-size: 20px; + letter-spacing: 4px; + font-weight: 600; + color: #888; +} + +.joke { + font-size: 36px; + letter-spacing: 1px; + text-align: center; +} + +button { + border: unset; + background-color: blueviolet; + color: #fff; + border-radius: 5px; + box-shadow: 0 5px 10px rgba(0, 0, 0, 0.6); + width: auto; + padding: 15px 30px; + font-size: 20px; + cursor: pointer; +} + +button:active { + transform: scale(0.96); + background-color: rgb(161, 72, 245); +}