用Trae帮我生成一个吃什么选择器

65 阅读1分钟

使用trae帮我生成简单的文字选择器,选择html,而非python。 image.png 让trae完善文字样式和添加图片 image.png

image.png 源代码:

<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>吃什么选择器</title>
    <style>
        body {
            font-family: 'Comic Sans MS', cursive, sans-serif;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            height: 100vh;
            margin: 0;
            background-image: url('https://images.unsplash.com/photo-1512621776951-a57141f2eefd?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=2070&q=80');
            background-size: cover;
            background-position: center;
            background-repeat: no-repeat;
        }
        button {
            padding: 15px 30px;
            font-size: 20px;
            cursor: pointer;
            background-color: #ff6b6b;
            color: white;
            border: none;
            border-radius: 25px;
            box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
            transition: all 0.3s ease;
        }
        button:hover {
            background-color: #e74c3c;
            transform: translateY(-2px);
        }
        #result {
            font-size: 36px;
            margin-top: 30px;
            font-weight: bold;
            color: #ffffff;
            text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
            background-color: rgba(0, 0, 0, 0.5);
            padding: 15px 30px;
            border-radius: 15px;
        }
        h1 {
            font-size: 48px;
            color: #ffffff;
            text-shadow: 3px 3px 6px rgba(0, 0, 0, 0.7);
            margin-bottom: 30px;
        }
    </style>
</head>
<body>
    <h1>今天吃什么?</h1>
    <button onclick="selectFood()">随机选择</button>
    <div id="result"></div>
    <script>
        const foodList = [
            "汉堡",
            "披萨",
            "寿司",
            "拉面",
            "炒饭",
            "火锅",
            "烧烤",
            "饺子",
            "煎饼果子",
            "麻辣烫"
        ];

        function selectFood() {
            const randomIndex = Math.floor(Math.random() * foodList.length);
            const selectedFood = foodList[randomIndex];
            document.getElementById('result').textContent = `今天吃:${selectedFood}`;
        }
    </script>
</body>
</html>

结果图: image.png