Skip to content
TheChatArchiveThe Chat Archive
chatgpt-4o-latest-20250326· OpenAIHugging Face LMArena Human Preference 140K

你是顶级前端工程师,现就职于apple. Create a single HTML file containing CSS and JavaScript to generate…

From a Chatbot Arena battleThe same person sent this prompt to two anonymous models at once. Compare it with gpt-4o-2024-11-20’s answer.
  1. User

    你是顶级前端工程师,现就职于apple.

    Create a single HTML file containing CSS and JavaScript to generate an animated weather card. The card should visually represent the following weather conditions with distinct animations: Wind: (e.g., moving clouds, swaying trees, or wind lines) Rain: (e.g., falling raindrops, puddles forming) Sun: (e.g., shining rays, bright background) Snow: (e.g., falling snowflakes, snow accumulating) Show all the weather card side by side The card should have a dark background. Provide all the HTML, CSS, and JavaScript code within this single file. The JavaScript should include a way to switch between the different weather conditions (e.g., a function or a set of buttons) to demonstrate the animations for each.

  2. Assistant

    当然!以下是一个完整的 HTML 文件,包含 CSS 和 JavaScript,用于展示四种天气动画卡片(风、雨、晴、雪),每种天气都有独特的动画效果。页面底部提供按钮,可切换显示不同天气的动画。

    你可以将以下代码保存为 .html 文件并在浏览器中打开查看效果:

    <!DOCTYPE html>
    <html lang="en">
    <head>
      <meta charset="UTF-8" />
      <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
      <title>Animated Weather Cards</title>
      <style>
        body {
          margin: 0;
          background-color: #121212;
          font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
          color: white;
          display: flex;
          flex-direction: column;
          align-items: center;
          padding: 20px;
        }
    
        h1 {
          margin-bottom: 20px;
        }
    
        .weather-container {
          display: flex;
          gap: 20px;
          flex-wrap: wrap;
          justify-content: center;
        }
    
        .weather-card {
          position: relative;
          width: 200px;
          height: 250px;
          background: #1e1e1e;
          border-radius: 15px;
          overflow: hidden;
          box-shadow: 0 0 15px rgba(0,0,0,0.5);
          display: flex;
          align-items: center;
          justify-content: center;
          font-size: 1.2em;
          text-align: center;
        }
    
        /* Common elements */
        .cloud {
          position: absolute;
          background: #ccc;
          border-radius: 50%;
          opacity: 0.8;
          animation: moveClouds 10s linear infinite;
        }
    
        @keyframes moveClouds {
          0% { left: -100px; }
          100% { left: 300px; }
        }
    
        .tree {
          position: absolute;
          bottom: 10px;
          width: 20px;
          height: 60px;
          background: #4caf50;
          border-radius: 10px;
          animation: sway 2s ease-in-out infinite alternate;
        }
    
        @keyframes sway {
          0% { transform: rotate(-5deg); }
          100% { transform: rotate(5deg); }
        }
    
        .raindrop {
          position: absolute;
          width: 2px;
          height: 10px;
          background: #00f;
          top: -10px;
          animation: fall 1s linear infinite;
        }
    
        @keyframes fall {
          0% { top: -10px; opacity: 1; }
          100% { top: 250px; opacity: 0; }
        }
    
        .sun {
          position: absolute;
          width: 80px;
          height: 80px;
          background: #ffeb3b;
          border-radius: 50%;
          box-shadow: 0 0 30px #ffeb3b;
          animation: pulse 2s ease-in-out infinite;
        }
    
        @keyframes pulse {
          0%, 100% { transform: scale(1); }
          50% { transform: scale(1.1); }
        }
    
        .ray {
          position: absolute;
          width: 4px;
          height: 30px;
          background: #ffeb3b;
          top: 10px;
          left: 50%;
          transform-origin: bottom center;
        }
    
        .ray:nth-child(1) { transform: rotate(0deg) translateY(-40px); }
        .ray:nth-child(2) { transform: rotate(45deg) translateY(-40px); }
        .ray:nth-child(3) { transform: rotate(90deg) translateY(-40px); }
        .ray:nth-child(4) { transform: rotate(135deg) translateY(-40px); }
    
        .snowflake {
          position: absolute;
          color: #fff;
          font-size: 1em;
          animation: snow 5s linear infinite;
        }
    
        @keyframes snow {
          0% { top: -10px; opacity: 1; }
          100% { top: 250px; opacity: 0; }
        }
    
        .buttons {
          margin-top: 30px;
        }
    
        .buttons button {
          background: #333;
          color: white;
          border: none;
          padding: 10px 15px;
          margin: 0 5px;
          border-radius: 5px;
          cursor: pointer;
          transition: background 0.3s;
        }
    
        .buttons button:hover {
          background: #555;
        }
    
        .hidden {
          display: none;
        }
      </style>
    </head>
    <body>
      <h1>Animated Weather Cards</h1>
      <div class="weather-container">
        <div class="weather-card" id="wind-card">
          <div class="cloud" style="top: 30px; width: 60px; height: 30px;"></div>
          <div class="cloud" style="top: 60px; width: 40px; height: 20px;"></div>
          <div class="tree" style="left: 80px;"></div>
          <div>Windy</div>
        </div>
    
        <div class="weather-card" id="rain-card">
          <div class="raindrop" style="left: 30px; animation-delay: 0s;"></div>
          <div class="raindrop" style="left: 60px; animation-delay: 0.2s;"></div>
          <div class="raindrop" style="left: 90px; animation-delay: 0.4s;"></div>
          <div class="raindrop" style="left: 120px; animation-delay: 0.6s;"></div>
          <div>Rainy</div>
        </div>
    
        <div class="weather-card" id="sun-card">
          <div class="sun"></div>
          <div class="ray"></div>
          <div class="ray"></div>
          <div class="ray"></div>
          <div class="ray"></div>
          <div>Sunny</div>
        </div>
    
        <div class="weather-card" id="snow-card">
          <div class="snowflake" style="left: 20px; animation-delay: 0s;">❄</div>
          <div class="snowflake" style="left: 60px; animation-delay: 1s;">❄</div>
          <div class="snowflake" style="left: 100px; animation-delay: 2s;">❄</div>
          <div class="snowflake" style="left: 140px; animation-delay: 3s;">❄</div>
          <div>Snowy</div>
        </div>
      </div>
    
      <div class="buttons">
        <button onclick="showOnly('wind')">Wind</button>
        <button onclick="showOnly('rain')">Rain</button>
        <button onclick="showOnly('sun')">Sun</button>
        <button onclick="showOnly('snow')">Snow</button>
        <button onclick="showAll()">Show All</button>
      </div>
    
      <script>
        function showOnly(type) {
          const cards = ['wind', 'rain', 'sun', 'snow'];
          cards.forEach(c => {
            document.getElementById(`${c}-card`).classList.add('hidden');
          });
          document.getElementById(`${type}-card`).classList.remove('hidden');
        }
    
        function showAll() {
          const cards = ['wind', 'rain', 'sun', 'snow'];
          cards.forEach(c => {
            document.getElementById(`${c}-card`).classList.remove('hidden');
          });
        }
      </script>
    </body>
    </html>
    

    🔧 说明:

    • 每张卡片使用不同的 DOM 元素和 CSS 动画来模拟天气效果。
    • 使用 @keyframes 实现云移动、树摇摆、雨滴下落、太阳脉冲、雪花飘落等动画。
    • 提供按钮切换显示单一天气或全部天气卡片。

    你可以根据需要进一步美化样式或添加更多天气类型。希望这个示例对你有帮助!🌤️

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.