<header>
<h1>Dad Jokes</h1>
</header>
<main>
<p class="joke"></p>
<button>Get a new Joke</button>
</main>
<footer>
<p>Created by <a href="https://remybeumier.be" target="_blank">Rémy Beumier</a></p>
</footer>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
min-height: 100vh;
text-align: center;
display: flex;
flex-direction: column;
justify-content: space-between;
align-items: center;
font-family: Arial;
background: linear-gradient(to top left, #5c6bc0, #90caf9);
}
header h1 {
color: white;
font-weight: normal;
padding: 20px;
letter-spacing: 0.1em;
display: none;
}
main {
padding: 10px;
}
main p.joke {
font-size: 28px;
font-family: ;
letter-spacing: 0.1em;
color: white;
margin-bottom: 30px;
}
button {
appearance: button;
font-size: 16px;
padding: 10px 20px;
background: white;
border: none;
cursor: pointer;
}
button:hover,
button:focus {
background: lightgray;
}
footer {
font-size: 14px;
padding: 10px;
color: white;
}
footer a {
text-decoration: none;
color: lightgray;
}
footer a:hover {
text-decoration: underline;
color: #fff;
}
getDJ();
function getDJ() {
// Ajax call to SW API
$.getJSON("https://icanhazdadjoke.com/", "Accept: application/json", function(json) {
var data = JSON.parse(JSON.stringify(json));
// console.log(data.joke);
$(".joke").html(data.joke);
});
}
$("button").on("click", getDJ);
This Pen doesn't use any external CSS resources.