<!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>Color Scheme Switcher</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<ul id="switcher">
<li id="grayButton"></li>
<li id="whiteButton"></li>
<li id="blueButton"></li>
<li id="yellowButton"></li>
</ul>
<h1>Color Scheme Switcher</h1>
<p>Lorem, ipsum dolor sit amet consectetur adipisicing elit. Cupiditate, officiis!</p>
<script src="script.js"></script>
</body>
</html>
body {
margin: 3rem;
padding: 0;
font-family: sans-serif;
font-size: 18px;
line-height: 1.5;
}
h1 {
line-height: 1.25;
margin: 2em 0 0;
}
p {
margin: .5rem 0;
}
#switcher {
list-style: none;
margin: 0;
padding: 0;
overflow: hidden;
}
#switcher li {
float: left;
width: 60px;
height: 30px;
margin: 0 15px 15px 0;
border-radius: 30px;
border: 3px solid black;
}
#grayButton {
background-color: gray;
}
#whiteButton {
background-color: white;
}
#blueButton {
background-color: blue;
}
#yellowButton {
background-color: yellow;
}
document.getElementById('grayButton').onclick = switchGray;
document.getElementById('whiteButton').onclick = switchWhite;
document.getElementById('blueButton').onclick = switchBlue;
document.getElementById('yellowButton').onclick = switchYellow;
function switchGray() {
document.getElementsByTagName('body')[0].style.backgroundColor = 'gray';
document.getElementsByTagName('body')[0].style.color = 'white';
}
function switchWhite() {
document.getElementsByTagName('body')[0].style.backgroundColor = 'white';
document.getElementsByTagName('body')[0].style.color = '#ffaa00';
}
function switchBlue() {
document.getElementsByTagName('body')[0].style.backgroundColor = 'blue';
document.getElementsByTagName('body')[0].style.color = 'white';
}
function switchYellow() {
document.getElementsByTagName('body')[0].style.backgroundColor = 'yellow';
document.getElementsByTagName('body')[0].style.color = 'black';
}
Result View Example
Document in project
You can Download PDF file.