parent
ad6a886453
commit
964dd03acf
@ -0,0 +1,25 @@
|
|||||||
|
<!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">
|
||||||
|
<title>10 dad jokes</title>
|
||||||
|
|
||||||
|
<link rel="stylesheet" href="style.css">
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<div class="container">
|
||||||
|
<span class="head">Try not to laugh</span>
|
||||||
|
<span class="joke" id="joke">Loading...</span>
|
||||||
|
|
||||||
|
<button id="btn" onclick="fetchJoke()">Another joke</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script src="script.js"></script>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
@ -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();
|
@ -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);
|
||||||
|
}
|
Loading…
Reference in new issue