暗传播发稿平台logo

随机生成色卡HTML

2025-01-08 21:23:29

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Color Palette</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            margin: 0;
            padding: 0;
            display: grid;
            grid-template-columns: repeat(30, 1fr);
            gap: 2px;
        }

        .color-card {
            width: 100%;
            height: 30px;
            display: flex;
            justify-content: center;
            align-items: center;
            color: white;
            font-size: 10px;
        }

        .color-code {
            background: rgba(0, 0, 0, 0.5);
            padding: 2px 4px;
            border-radius: 2px;
        }
    </style>
</head>
<body>
<script>
    function generateColors() {
        const body = document.body;
        for (let i = 0; i < 900; i++) { // 30 x 30 = 900
            const color = `#${Math.floor(Math.random() * 16777215).toString(16).padStart(6, '0')}`;
            const div = document.createElement('div');
            div.className = 'color-card';
            div.style.backgroundColor = color;
            div.innerHTML = `<div class='color-code'>${color}</div>`;
            body.appendChild(div);
        }
    }
    generateColors();
</script>
</body>
</html>

推荐内容

关于我们

2024-03-28 10:07:19
暗传播
咨询图标