全部效果静态视觉样式

描边文字

Text Outline

描边沿每个字形的轮廓绘制,即使内部透明也能辨认文字。

观察文字描边和字形中露出的背景

适用场景

在简洁背景上制作有装饰感的大标题。 把描边留给字数少、字号大的主标题,并检查窄屏上轮廓是否仍然清楚。

应用示例

一本独立杂志的字体专刊用整版的「TYPE」做封面。标题沿字形描边,浅色纸纹从笔画内部露出来,期号和文章目录则用实心文字排在下方。

AI 提示词

给【目标标题】加描边文字。先声明清楚的纯色文字作为备用,再为支持的浏览器加描边和透明填充。保留真实文字,强制颜色或低对比场景恢复实色填充。

示例代码

保存为 HTML 文件后,用浏览器打开即可运行。代码与页面里的演示一致。

查看 HTML
<!doctype html>
<html lang="zh">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>描边文字</title>
  <style>
    :root {
      color-scheme: dark;
      --demo-bg: #171629;
      --demo-ink: #f8f5ff;
      --demo-accent: #b9a6ff;
      --demo-muted: #bfbbd3;
      font-family: system-ui, sans-serif;
      color: var(--demo-ink);
      background: var(--demo-bg);
    }

    *, *::before, *::after { box-sizing: border-box; }
    body { margin: 0; min-width: 0; }
    button, input { font: inherit; }

    .demo {
      display: grid;
      place-items: center;
      align-content: center;
      min-height: 100vh;
      padding: 14px;
      overflow: hidden;
      background: radial-gradient(ellipse at 50% 24%, #28233f, var(--demo-bg) 78%);
    }

    .demo-button {
      border: 1px solid #ffffff3d;
      border-radius: 7px;
      background: #ffffff12;
      color: var(--demo-ink);
      padding: 6px 11px;
      font-size: 12px;
      cursor: pointer;
    }

    :focus-visible {
      outline: 2px solid var(--demo-accent);
      outline-offset: 3px;
    }

    .visual-specimen {
      width: min(100%, 290px);
      height: 124px;
      display: grid;
      place-items: center;
      position: relative;
      isolation: isolate;
    }
    .outline-word { font-size: clamp(24px, 12vw, 39px); line-height: 1.1; letter-spacing: .06em; color: #e9caa4; }
    @supports (-webkit-text-stroke: 1px #e9caa4) {
      .outline-word { -webkit-text-stroke: 1.4px #e9caa4; -webkit-text-fill-color: transparent; }
    }
    @media (forced-colors: active) {
      .outline-word { -webkit-text-stroke: 0; -webkit-text-fill-color: currentColor; }
    }
  </style>
</head>
<body>
  <main class="demo">
    <div class="visual-specimen" aria-hidden="true"><b class="outline-word">轮廓</b></div>
  </main>
</body>
</html>

UI Skills 原创示例