JSFiddle - React, Tailwind, and code Playground
HTML
<!DOCTYPE html>
<html lang="de">
<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>Ratespiel</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Noto+Sans+JP:wght@400;500;700;900&display=swap" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css">
<link rel="stylesheet" href="style.css">
</head>
<body>
<div id="start">
<p>Willkommen zum Musik-Quiz!</p>
<p>Die <span id="countQa"></span> Fragen sind teils ernst-, teils scherzhaft gemeint.</p>
<button id="starter" class="blink">Start</button>
</div>
<div id="oneMoreTime">
<p><i class="fas fa-frown"></i> Das war wohl nichts ...</p>
<p>Die <span id="countQa"></span> Du kannst es aber noch einmal von vorn versuchen.</p>
<button id="repeater" class="blink">Start</button>
</div>
<div id="question">
<p id="one"></p>
<p id="two"></p>
</div>
<div id="answer">
<label id="three"></label>
<label id="four"></label>
<label id="five"></label>
<label id="six"></label>
<p id="solution"></p>
<button id="button">nächste Frage</button>
<div id="end">Das war's!</div>
</div>
<script src="main.js"></script>
</body>
</html>
CSS
body,
button {
font-family: "Noto Sans JP", sans-serif;
font-size: 1rem;
color: #444;
background-color: lightskyblue;
}
* {
box-sizing: border-box;
}
p {
margin: 0;
}
p#one {
font-weight: 700;
margin-bottom: 0.5rem;
}
#start {
display: block;
}
#start p:first-of-type,
#oneMoreTime p:first-of-type {
font-size: 150%;
font-weight: 800;
margin-bottom: 0.5rem;
color: coral;
}
#oneMoreTime p:first-of-type {
color: crimson;
}
#oneMoreTime > p:nth-child(1) > i {
color: crimson;
font-size: 4rem;
margin-right: 1.2rem;
}
#start button,
#oneMoreTime button {
color: white;
background-color: coral;
margin: 2rem 0 0.5rem;
padding: 0.7rem;
font-size: 1.2rem;
font-weight: 700;
cursor: pointer;
display: block;
animation: blink 1.5s infinite;
}
@keyframes blink {
from {
background-color: coral;
}
35% {
background-color: coral;
}
36% {
background-color: darkorange;
}
64% {
background-color: darkorange;
}
65% {
background-color: coral;
}
to {
background-color: coral;
}
}
#question,
#answer,
#oneMoreTime {
display: none;
}
div {
width: 100%;
margin: 1.5rem auto;
padding: 1rem;
background-color: aliceblue;
border-radius: 1rem;
box-shadow: 0 0 1rem rgba(0, 0, 0, 0.2);
}
@media (min-width: 768px) {
div {
width: 70vw;
}
}
@media (min-width: 992px) {
div {
width: 50vw;
}
}
@media (min-width: 1200px) {
div {
width: 35vw;
}
}
#solution {
display: none;
margin: 3rem 0 1rem;
border-radius: 1rem;
padding: 1rem;
left: 0 !important;
}
#solution i {
color: white;
font-size: 1.5rem;
margin-right: 1rem;
}
.rightAnswer {
color: #444;
background-color: yellowgreen;
}
button,
#end {
display: none;
width: 100%;
margin-top: 2rem;
border-radius: 1rem;
border-style: none;
color: white;
background-color: cornflowerblue;
font-size: 1rem;
padding: 1rem;
}
button:hover {
background-color: rgb(14, 135,...
JavaScript
'use strict'
// Array Fragen und Antworten
const questions = [
{
two: 'Welche Band veröffentlichte 1980 das Album "Paris"?',
three: '<input type="radio" name="fourQuestions" class="wrongAnswer"> <span></span> <p>Queen</p>',
four: '<input type="radio" name="fourQuestions" class="wrongAnswer"> <span></span> <p>Visage</p>',
five: '<input type="radio" name="fourQuestions" id="rightAnswer"> <span></span> <p>Supertramp</p>',
six: '<input type="radio" name="fourQuestions" class="wrongAnswer"> <span></span> <p>ELO</p>'
},
{
two: 'Wie hieß der Chef der Dire Straits?',
three: '<input type="radio" name="fourQuestions" class="wrongAnswer"> <span></span> <p>Knark Mopfler</p>',
four: '<input type="radio" name="fourQuestions" class="wrongAnswer"> <span></span> <p>Kropf Markler</p>',
five: '<input type="radio" name="fourQuestions" class="wrongAnswer"> <span></span> <p>Krank Flomper</p>',
six: '<input type="radio" name="fourQuestions" id="rightAnswer"> <span></span> <p>Mark Knopfler</p>'
},
{
two: 'Auf welchem Pink-Floyd-Album wird eine Atombombe abgeworfen?',
three: '<input type="radio" name="fourQuestions" class="wrongAnswer"> <span></span> <p>The Wall</p>',
four: '<input type="radio" name="fourQuestions" id="rightAnswer"> <span></span> <p>The Final Cut</p>',
five: '<input type="radio" name="fourQuestions" class="wrongAnswer"> <span></span> <p>The Endless River</p>',
six: '<input type="radio" name="fourQuestions" class="wrongAnswer"> <span></span> <p>The Dark Side of the Moon</p>'
},
{
two: 'Wie hieß der Sänger der Scorpions?',
three: '<input type="radio" name="fourQuestions" class="wrongAnswer"> <span></span> <p>Kleine Maus</p>',
four: '<input type="radio" name="fourQuestions" class="wrongAnswer"> <span></span> <p>Klaun Meise</p>',
five: '<input type="radio" name="fourQuestions" id="rightAnswer"> <span></span> <p>Klaus Meine</p>',
six: '<input type="radio" name="fourQuestions"...