js+css实现中式动画天气卡片代码

代码语言:html

所属分类:动画

代码描述:js+css实现中式动画天气卡片代码

代码标签: js css 中式 动画 天气 卡片 代码

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

<!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>
    :root {
      color-scheme: dark;
    }

    * {
      box-sizing: border-box;
    }

    html,
    body {
      margin: 0;
      min-height: 100%;
    }

    body {
      display: flex;
      align-items: center;
      justify-content: center;
      padding: 28px 16px;
      background:
        radial-gradient(circle at top, rgba(255, 215, 157, 0.18), transparent 28%),
        linear-gradient(180deg, #17120f 0%, #231b16 48%, #110d0b 100%);
      color: #f6ecda;
      font-family: "Microsoft YaHei", "PingFang SC", "Helvetica Neue", Arial, sans-serif;
      overflow-x: hidden;
    }

    body::before {
      content: "";
      position: fixed;
      inset: 0;
      pointer-events: none;
      opacity: 0.22;
      background:
        repeating-linear-gradient(
          90deg,
          rgba(255, 255, 255, 0.03) 0 1px,
          transparent 1px 130px
        ),
        repeating-linear-gradient(
          0deg,
          rgba(255, 255, 255, 0.02) 0 1px,
          transparent 1px 120px
        );
    }

    .app {
      width: min(1120px, 100%);
      position: relative;
      z-index: 1;
    }

    .header {
      text-align: center;
      margin-bottom: 22px;
    }

    .seal {
      width: 58px;
      height: 58px;
      margin: 0 auto 12px;
      border-radius: 14px;
      background: linear-gradient(180deg, #d24434, #8d1e17);
      display: grid;
      place-items: center;
      box-shadow: 0 16px 30px rgba(0, 0, 0, 0.28);
      border: 1px solid rgba(255, 230, 210, 0.22);
      font-family: "STKaiti", "KaiTi", "Songti SC", serif;
      font-size: 24px;
      letter-spacing: 2px;
      color: #fff4ee;
    }

    .header h1 {
      margin: 0;
      font-size: clamp(30px, 4vw, 48px);
      font-weight: 400;
      letter-spacing: 3px;
      font-family: "STKaiti", "KaiTi", "Songti SC", serif;
      text-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
    }

    .header p {
      margin: 8px 0 0;
      color: rgba(246, 236, 218, 0.78);
      font-size: 15px;
      letter-spacing: 1px;
    }

    .switcher {
      display: flex;
      justify-content: center;
      flex-wrap: wrap;
      gap: 12px;
      margin-bottom: 22px;
    }

    .weather-tab {
      appearance: none;
      border: 1px solid rgba(255, 231, 194, 0.16);
      background: linear-gradient(180deg, rgba(255, 250, 238, 0.10), rgba(255, 246, 228, 0.04));
      color: #f3ead8;
      border-radius: 999px;
      padding: 10px 18px;
      min-width: 118px;
      cursor: pointer;
      transition: transform 0.25s ease, box-shadow 0.25s ease, background 0.25s ease, color 0.25s ease;
      box-shadow: 0 10px 24px rgba(0, 0, 0, 0.18);
      backdrop-filter: blur(10px);
    }

    .weather-tab:hover {
      transform: translateY(-2px);
    }

    .weather-tab.active {
      color: #2d190b;
      background: linear-gradient(180deg, #f4d7a4, #d9a45d);
      box-shadow: 0 14px 30px rgba(192, 129, 55, 0.28);
      border-color: rgba(255, 228, 183, 0.35);
    }

    .weather-tab .cn {
      display: block;
      font-size: 18px;
      line-height: 1.1;
      font-family: "STKaiti", "KaiTi", "Songti SC", serif;
    }

    .weather-tab .en {
      display: block;
      font-size: 11px;
      opacity: 0.7;
      letter-spacing: 1px;
      margin-top: 3px;
    }

    .stage {
      position: relative;
      height: clamp(470px, 72vh, 640px);
    }

    .weather-card {
      position: absolute;
      inset: 0;
      border-radius: 30px;
      overflow: hidden;
      opacity: 0;
      transform: translateY(16px) scale(0.985);
      transition: opacity 0.7s ease, transform 0.7s ease;
      pointer-events: none;
      border: 1px solid rgba(255, 232, 194, 0.14);
      background: #0d0b0a;
      box-shadow:
        0 32px 80px rgba(0, 0, 0, 0.42),
        inset 0 0 0 1px rgba(255, 253, 246, 0.02);
    }

    .weather-card.active {
      opacity: 1;
      transform: translateY(0) scale(1);
      pointer-events: auto;
    }

    .weather-card::before {
      content: "";
      position: absolute;
      inset: 12px;
      border-radius: 22px;
      border: 1px solid rgba(255, 230, 183, 0.16);
      pointer-events: none;
      z-index: 12;
    }

    .weather-card::after {
      content: "";
      position: absolute;
      inset: 0;
      pointer-events: none;
      z-index: 11;
      background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent 24%, rgba(0, 0, 0, 0.06) 100%),
        radial-gradient(circle at 20% 15%, rgba(255, 255, 255, 0.08), transparent 24%);
    }

    .scene {
      position: absolute;
      inset: 0;
      overflow: hidden;
    }

    .sky {
      position: absolute;
      inset: 0;
      background: linear-gradient(180deg, var(--sky-top), var(--sky-mid) 52%, var(--sky-bottom));
    }

    .sky-glow {
      position: absolute;
      inset: 0;
      background:
        radial-gradient(circle at 78% 20%, var(--orb-glow), transparent 26%),
        radial-gradient(circle at 15% 8%, rgba(255, 255, 255, 0.10), transparent 18%);
      pointer-events: none;
    }

    .sun,
    .moon {
      position: absolute;
      right: 9%;
      top: 11%;
      width: 120px;
      height: 120px;
      border-radius: 50%;
      z-index: 2;
    }

    .sun {
      background:
        radial-gradient(circle at 38% 36%, rgba(255, 255, 255, 0.95), rgba(255, 244, 203, 0.95) 28%, rgba(255, 194, 109, 0.96) 68%, rgba(255, 194, 109, 0.2) 100%);
      box-shadow:
        0 0 36px rgba(255, 193, 96, 0.52),
        0 0 120px rgba(255, 194, 96, 0.28);
    }

 .........完整代码请登录后点击上方下载按钮下载查看

网友评论0