Communitygithub.com

英雄區段

設計與建置網站的首頁英雄區段(第一屏),包括標題佈局、媒體處理、行動呼籲、信任徽章、跑馬燈與進場動畫。每當有人要求設計英雄區段、登陸頁面頂部、網站首頁上方、電影感或動畫開場、影片背景、文字跑馬燈,或覺得首屏看起來平淡無奇時,請使用此技能。

英雄區段 是什麼?

此技能專注於為網站創作引人注目且效能優化的英雄區段(第一屏)。它能引導使用者根據專案類型(如強烈定位、產品展示、電影感品牌、工作室風格或作品集牆)選擇最合適的佈局模式,並提供具體的內容規則(如標題長度、行動呼籲措辭、信任元素放置)以避免常見的設計陷阱。技能支援多種現代前端技術,包含 GSAP 進場動畫(逐行標題揭示、內容淡入)、滾動觸發的媒體縮放、無限循環跑馬燈,以及影片背景的正確實作方式(確保行動裝置自動播放與效能考量)。此外,它還涵蓋了響應式設計(最小高度、字型大小彈性調整)與效能檢查清單(LCP 低於 2.5 秒、輔助功能支援減少動畫),協助開發者打造既美觀又快速的首屏體驗。此技能適用於 Claude Code、Cursor 或任何支援 Markdown 指令的 AI 編碼助手。

相容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/imperfec-t/webcraft/tree/main/skills/hero-section

在你喜歡的 AI 中提問

開啟一個已預先載入此 Agent Skill 的新對話。

說明文件

英雄區段 是做什麼的?

英雄區段決定訪客是否繼續往下滑。它必須清楚傳達這是什麼、看起來經過精心設計,並且載入迅速。大多數失敗的英雄區段是在第一點或第三點出錯,而不是第二點。

先決定模式

選擇一種。混合使用只會讓英雄區段變得雜亂。

模式使用時機核心結構
文字主導強烈定位,沒有出色的圖片超大多行標題、小支援行、行動呼籲
分割式有產品、人物或螢幕截圖要展示文字左、媒體右,55/45 比例
滿版媒體電影感品牌、強烈的影片或照片媒體填滿畫面,文字疊加在遮罩上
堆疊式媒體卡片代理商或工作室風格標題在上方,下方是圓角媒體區塊,隨滾動放大
作品集牆設計師、攝影師小簡介行位於作品網格或輪播上方

內容規則

  • 標題: 說明你做什麼、為誰而做,6 到 12 個字。對於文字主導的英雄區段,將標題拆成 2 或 3 行長度相近的短行,讓區塊讀起來像一個形狀。
  • 支援行: 一句話,最多 20 個字。補充標題遺漏的細節。
  • 行動呼籲: 動詞加上結果(例如「規劃你的專案」),一個主要按鈕。加上次要文字連結也可以。
  • 信任元素: 一個小徽章放在行動呼籲附近或重疊在媒體上:評分、計數或客戶標誌。僅使用真實數字。
  • 不要 在英雄區段中放置段落、超過兩個欄位的表單或滑桿。

佈局細節

  • 標題尺寸:clamp(2.5rem, 7vw, 6.5rem),行高 0.95 到 1.05,大型顯示字型字距 -0.02em 到 -0.04em。
  • 英雄區段高度:僅滿版媒體使用 min-height: 100svh;否則讓內容決定高度,讓下一個區塊稍微露出。
  • 媒體圓角:堆疊模式使用 16 到 32px 半徑。全站保持統一半徑。
  • 文字疊加在媒體上需要遮罩:從 60% 黑色到透明的漸層,否則 4.5:1 對比度會失敗。

有幫助的動畫

進場順序:標題行、然後支援行與行動呼籲、接著媒體、最後裝飾元素。總時間低於 1.6 秒,因為訪客正在等待。

// 逐行標題揭示。將每行包在:<span class="line"><span>Text</span></span>
// .line { display:block; overflow:hidden }  .line > span { display:block }
gsap.from(".hero .line > span", {
  yPercent: 110, duration: 0.9, ease: "power3.out", stagger: 0.08
});
gsap.from(".hero [data-fade]", {
  y: 24, opacity: 0, duration: 0.7, ease: "power2.out", stagger: 0.08, delay: 0.35
});

隨滾動放大的媒體:

gsap.fromTo(".hero-media", { scale: 0.86, borderRadius: 32 }, {
  scale: 1, borderRadius: 0, ease: "none",
  scrollTrigger: { trigger: ".hero-media", start: "top 85%", end: "top 15%", scrub: true }
});

無限跑馬燈(複製軌道內容一次以實現無縫循環):

.marquee { overflow: hidden; }
.marquee__track { display: flex; gap: 3rem; width: max-content; animation: marquee 28s linear infinite; }
@keyframes marquee { to { transform: translateX(-50%); } }
@media (prefers-reduced-motion: reduce) { .marquee__track { animation: none; } }

影片背景

  • 設定 autoplay muted loop playsinline 加上 poster 圖片;沒有 muted 和 playsinline,行動瀏覽器將無法自動播放。
  • 保持低於 3 MB:8 到 12 秒、1280px 寬、無音軌、H.264 MP4 並提供 WebM 替代格式。
  • 絕對不要讓影片成為 LCP 阻塞因素:poster 應該是預先載入的圖片。
  • 在小螢幕或 prefers-reduced-motion 啟用時,僅顯示 poster。

檢查清單

  • 遮住標題:陌生人還能從其餘內容看出這個企業是做什麼的嗎?如果能,表示標題太模糊。
  • 在 390px 寬的首屏中,標題、行動呼籲和部分媒體無需滾動即可看見。
  • 在節流連線下,最大內容繪製時間低於 2.5 秒。
  • 停用動畫時,沒有任何內容隱形或錯位。

Individual skills in this repo

This repo contains 4 individual skills — each has its own dedicated page.

homepage-blueprint

Plan the section structure and content slots of a homepage for an agency, freelancer, studio or service business before any design or code. Use this whenever someone asks "what sections should my homepage have", "plan my website", "structure a landing page for my business", wants a wireframe or sitemap for a service site, or starts building a homepage without a clear outline.

responsive-layout

Build page layouts that work from phones to wide desktops using CSS grid, flexbox, container queries and fluid sizing, including card grids, bento grids, split sections, sticky sidebars and navigation that collapses. Use this whenever someone says their site "breaks on mobile", asks for a responsive grid, a bento layout, a mobile menu, fixing horizontal scroll or overflow, or is laying out any multi-column section.

scroll-motion

Add scroll-driven and entrance animation to a website with GSAP, ScrollTrigger and Lenis, including reveals, parallax, pinned sections, horizontal scroll, line drawing, counters and preloaders. Use this whenever someone wants a site to "feel premium", asks for smooth scrolling, scroll animations, parallax, text reveals, a pinned or sticky scroll section, an animated preloader, or names GSAP, ScrollTrigger, Lenis, Locomotive or AOS.

website-workflow

Plan and sequence a whole website build, from structure through design, code, WordPress and launch, by routing each stage to the right webcraft skill. Use this when someone asks to "build me a website", "design my site from scratch", "redo our homepage", wants an end-to-end plan for a marketing, agency, studio or service site, or the request spans more than one of structure, look, layout, motion, CMS and QA.

相關技能