Untitled
unknown
plain_text
a year ago
1.6 kB
13
Indexable
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Color Boxes</title>
<style>
body {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 100vh;
background-color: white;
}
.color-box {
width: 100px;
height: 100px;
margin: 10px;
display: flex;
align-items: center;
justify-content: center;
color: white;
font-weight: bold;
cursor: pointer;
border: 2px solid #ccc;
border-radius: 5px;
transition: transform 0.2s;
}
.color-box:hover {
transform: scale(1.1);
}
</style>
</head>
<body>
<h1>Change Background Color</h1>
<div class="color-box" style="background-color: blue;" onclick="changeBackground('blue')">Blue</div>
<div class="color-box" style="background-color: red;" onclick="changeBackground('red')">Red</div>
<div class="color-box" style="background-color: orange;" onclick="changeBackground('orange')">Orange</div>
<div class="color-box" style="background-color: yellow;" onclick="changeBackground('yellow')">Yellow</div>
<script>
function changeBackground(color) {
document.body.style.backgroundColor = color;
}
</script>
</body>
</html>
Editor is loading...
Leave a Comment