Untitled

mail@pastecode.io avatar
unknown
plain_text
16 days ago
1.6 kB
1
Indexable
Never
<!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>
Leave a Comment