revealjs
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseReveal.js Presentations
Reveal.js 演示文稿
Create HTML presentations using reveal.js. No build step required - just open the HTML in a browser.
使用reveal.js创建HTML演示文稿。无需构建步骤——只需在浏览器中打开HTML文件即可。
What You Create
你将创建的内容
A reveal.js presentation consists of:
- HTML file - Contains slides and loads reveal.js from CDN
- CSS file - Custom styles for layouts, colors, typography, and components
一个reveal.js演示文稿包含:
- HTML文件 - 包含幻灯片内容,并从CDN加载reveal.js
- CSS文件 - 用于布局、颜色、排版和组件的自定义样式
Design Principles
设计原则
CRITICAL: Before creating any presentation, analyze the content and choose appropriate design elements:
- Consider the subject matter: What is this presentation about? What tone, industry, or mood does it suggest?
- Check for branding: If the user mentions a company/organization, consider their brand colors and identity
- Match palette to content: Select colors that reflect the subject
- State your approach: Explain your design choices before writing code
Requirements:
- ✅ State your content-informed design approach BEFORE writing code
- ✅ Use web-safe fonts (Arial, Helvetica, Georgia, Verdana, etc.) or Google Fonts via in CSS
@import - ✅ Create clear visual hierarchy through size, weight, and color
- ✅ Ensure readability: strong contrast, appropriately sized text, clean alignment
- ✅ Be consistent: repeat patterns, spacing, and visual language across slides
- ✅ Always use (points) for font sizes - slides are fixed-size, so
ptis predictable and familiar (like PowerPoint/Keynote). Never usept,em, orremfor font sizes.px
关键要求:在创建任何演示文稿之前,先分析内容并选择合适的设计元素:
- 考虑主题内容:这个演示文稿是关于什么的?它需要呈现什么样的基调、行业或氛围?
- 检查品牌要求:如果用户提到了公司/组织,要考虑他们的品牌颜色和视觉标识
- 匹配内容的调色板:选择能反映主题的颜色
- 说明设计思路:在编写代码之前,先解释你的设计选择
必须满足的要求:
- ✅ 在编写代码之前,先说明基于内容的设计思路
- ✅ 使用网络安全字体(Arial、Helvetica、Georgia、Verdana等)或通过CSS中的引入Google Fonts
@import - ✅ 通过字号、字重和颜色创建清晰的视觉层次
- ✅ 确保可读性:高对比度、合适的字号、整齐的对齐方式
- ✅ 保持一致性:在所有幻灯片中重复使用相同的布局模式、间距和视觉语言
- ✅ 始终使用(磅)作为字体单位 - 幻灯片是固定尺寸的,因此
pt是可预测且常用的单位(与PowerPoint/Keynote一致)。绝对不要使用pt、em或rem作为字体单位。px
Color Palette Selection
调色板选择
Choosing colors creatively:
- Think beyond defaults: What colors genuinely match this specific topic? Avoid autopilot choices.
- Consider multiple angles: Topic, industry, mood, energy level, target audience, brand identity (if mentioned)
- Be adventurous: Try unexpected combinations - a healthcare presentation doesn't have to be green, finance doesn't have to be navy
- Build your palette: Pick 3-5 colors that work together (dominant colors + supporting tones + accent)
- Ensure contrast: Text must be clearly readable on backgrounds
Example color palettes (use these to spark creativity - choose one, adapt it, or create your own):
- Classic Blue: Deep navy (#1C2833), slate gray (#2E4053), silver (#AAB7B8), off-white (#F4F6F6)
- Teal & Coral: Teal (#5EA8A7), deep teal (#277884), coral (#FE4447), white (#FFFFFF)
- Bold Red: Red (#C0392B), bright red (#E74C3C), orange (#F39C12), yellow (#F1C40F), green (#2ECC71)
- Warm Blush: Mauve (#A49393), blush (#EED6D3), rose (#E8B4B8), cream (#FAF7F2)
- Burgundy Luxury: Burgundy (#5D1D2E), crimson (#951233), rust (#C15937), gold (#997929)
- Deep Purple & Emerald: Purple (#B165FB), dark blue (#181B24), emerald (#40695B), white (#FFFFFF)
- Cream & Forest Green: Cream (#FFE1C7), forest green (#40695B), white (#FCFCFC)
- Pink & Purple: Pink (#F8275B), coral (#FF574A), rose (#FF737D), purple (#3D2F68)
- Lime & Plum: Lime (#C5DE82), plum (#7C3A5F), coral (#FD8C6E), blue-gray (#98ACB5)
- Black & Gold: Gold (#BF9A4A), black (#000000), cream (#F4F6F6)
- Sage & Terracotta: Sage (#87A96B), terracotta (#E07A5F), cream (#F4F1DE), charcoal (#2C2C2C)
- Charcoal & Red: Charcoal (#292929), red (#E33737), light gray (#CCCBCB)
- Vibrant Orange: Orange (#F96D00), light gray (#F2F2F2), charcoal (#222831)
- Forest Green: Black (#191A19), green (#4E9F3D), dark green (#1E5128), white (#FFFFFF)
- Retro Rainbow: Purple (#722880), pink (#D72D51), orange (#EB5C18), amber (#F08800), gold (#DEB600)
- Vintage Earthy: Mustard (#E3B448), sage (#CBD18F), forest green (#3A6B35), cream (#F4F1DE)
- Coastal Rose: Old rose (#AD7670), beaver (#B49886), eggshell (#F3ECDC), ash gray (#BFD5BE)
- Orange & Turquoise: Light orange (#FC993E), grayish turquoise (#667C6F), white (#FCFCFC)
创意选择颜色:
- 超越默认选项:哪些颜色真正匹配这个特定主题?避免机械性选择。
- 多角度考虑:主题、行业、氛围、活力水平、目标受众、品牌标识(如果有提及)
- 大胆尝试:试试意想不到的组合——医疗行业的演示文稿不一定非要用绿色,金融行业也不一定非要用深蓝色
- 构建你的调色板:选择3-5种搭配和谐的颜色(主色调 + 辅助色调 + 强调色)
- 确保对比度:文本在背景上必须清晰可读
示例调色板(用于激发创意——可以选择其中一个、修改它,或者创建自己的调色板):
- 经典蓝色:深藏青(#1C2833)、石板灰(#2E4053)、银色(#AAB7B8)、米白(#F4F6F6)
- 蓝绿色与珊瑚色:蓝绿色(#5EA8A7)、深绿蓝(#277884)、珊瑚红(#FE4447)、白色(#FFFFFF)
- 醒目红色:红色(#C0392B)、亮红色(#E74C3C)、橙色(#F39C12)、黄色(#F1C40F)、绿色(#2ECC71)
- 暖粉色调:淡紫色(#A49393)、腮红粉(#EED6D3)玫瑰粉(#E8B4B8)、奶油色(#FAF7F2)
- 勃艮第奢华风:勃艮第红(#5D1D2E)、深红(#951233)、铁锈红(#C15937)、金色(#997929)
- 深紫与祖母绿:紫色(#B165FB)、深蓝色(#181B24)、祖母绿(#40695B)、白色(#FFFFFF)
- 奶油色与森林绿:奶油色(#FFE1C7)、森林绿(#40695B)、白色(#FCFCFC)
- 粉色与紫色:粉色(#F8275B)、珊瑚橙(#FF574A)、玫瑰红(#FF737D)、紫色(#3D2F68)
- 石灰绿与李子紫:石灰绿(#C5DE82)、李子紫(#7C3A5F)、珊瑚橙(#FD8C6E)、蓝灰色(#98ACB5)
- 黑金配色:金色(#BF9A4A)、黑色(#000000)、奶油色(#F4F6F6)
- 鼠尾草绿与赤陶色:鼠尾草绿(#87A96B)、赤陶色(#E07A5F)、奶油色(#F4F1DE)、炭灰色(#2C2C2C)
- 炭灰与红色:炭灰色(#292929)、红色(#E33737)、浅灰色(#CCCBCB)
- 活力橙色:橙色(#F96D00)、浅灰色(#F2F2F2)、炭灰色(#222831)
- 森林绿:黑色(#191A19)、绿色(#4E9F3D)、深绿色(#1E5128)、白色(#FFFFFF)
- 复古彩虹:紫色(#722880)、粉色(#D72D51)、橙色(#EB5C18)、琥珀色(#F08800)、金色(#DEB600)
- 复古大地色:芥末黄(#E3B448)、鼠尾草绿(#CBD18F)、森林绿(#3A6B35)、奶油色(#F4F1DE)
- 海岸玫瑰色:旧玫瑰色(#AD7670)、海狸棕(#B49886)、蛋壳白(#F3ECDC)、灰绿色(#BFD5BE)
- 橙色与绿松石色:浅橙色(#FC993E)、灰绿松石色(#667C6F)、白色(#FCFCFC)
Slide Content Principles
幻灯片内容原则
Diverse presentation is key. Even when slides have similar content types, vary the visual presentation:
- Use different layouts across slides: columns on one, stacked boxes on another, callouts with icons on a third
- Mix container styles: plain text, boxes, callouts, blockquotes
- Use visual hierarchy: for key terms, different colors to distinguish categories
<strong> - Break up lists with other elements (quotes, callouts, columns)
- Don't repeat the same layout pattern on consecutive slides
Keep it scannable:
- Short bullet points, not paragraphs
- One main idea per slide when possible
- Use icons (Font Awesome) to add visual interest
When a slide has less content, make it bigger - don't leave empty space with tiny text.
多样化呈现是关键。即使幻灯片内容类型相似,也要改变视觉呈现方式:
- 在不同幻灯片中使用不同布局:一张用多列布局,下一张用堆叠框,再下一张用带图标提示框
- 混合容器样式:纯文本、方框、提示框、引用块
- 使用视觉层次:用标记关键术语,用不同颜色区分类别
<strong> - 用其他元素(引用、提示框、多列)打破列表的单调
- 不要在连续幻灯片中重复使用相同的布局模式
保持内容易扫描:
- 使用短要点,而非段落
- 尽可能每张幻灯片只表达一个核心观点
- 使用图标(Font Awesome)增加视觉趣味
当幻灯片内容较少时,放大内容 - 不要留着大量空白却用很小的文字。
Workflow
工作流程
Step 1: Plan the Structure
步骤1:规划结构
Based on the user's content, determine:
- How many slides are needed
- Which slides should be section dividers (centered, larger text)
- Where to use vertical slide stacks for drill-down content
根据用户提供的内容,确定:
- 需要多少张幻灯片
- 哪些幻灯片作为章节分隔页(居中、大字号文本)
- 在哪里使用垂直幻灯片组来展示深度内容
Step 2: Generate the Scaffold
步骤2:生成基础框架
Use the script (located in the directory next to this SKILL.md file) to generate the HTML scaffold.
create-presentation.jsscripts/bash
node <path-to-skill>/scripts/create-presentation.js --structure 1,1,d,3,1,d,1 --title "My Presentation" --output presentation.htmlFinding the script path: The script is at relative to where this SKILL.md file is located. Common locations:
scripts/create-presentation.js- Project skill:
.claude/skills/revealjs/scripts/create-presentation.js - User skill:
~/.claude/skills/revealjs/scripts/create-presentation.js
Options:
- - Create N horizontal slides (simple mode)
--slides N - - Mixed layout with comma-separated values:
--structure <list>- = single horizontal slide
1 - (where N > 1) = vertical stack of N slides
N - = section divider slide (centered, no content wrapper)
d
- - Output filename (default: presentation.html)
--output <file> - - Presentation title
--title <text> - - Custom CSS filename (default: styles.css)
--styles <file>
Examples:
bash
undefined使用脚本(位于本SKILL.md文件所在目录的文件夹中)生成HTML基础框架。
create-presentation.jsscripts/bash
node <path-to-skill>/scripts/create-presentation.js --structure 1,1,d,3,1,d,1 --title "My Presentation" --output presentation.html查找脚本路径:该脚本位于本SKILL.md文件所在目录的。常见位置:
scripts/create-presentation.js- 项目技能:
.claude/skills/revealjs/scripts/create-presentation.js - 用户技能:
~/.claude/skills/revealjs/scripts/create-presentation.js
选项说明:
- - 创建N张水平幻灯片(简单模式)
--slides N - - 混合布局,用逗号分隔的值:
--structure <list>- = 单张水平幻灯片
1 - (N>1)= 包含N张幻灯片的垂直组
N - = 章节分隔页幻灯片(居中,无内容容器)
d
- - 输出文件名(默认:presentation.html)
--output <file> - - 演示文稿标题
--title <text> - - 自定义CSS文件名(默认:styles.css)
--styles <file>
示例:
bash
undefined10 horizontal slides
10张水平幻灯片
node <path-to-skill>/scripts/create-presentation.js --slides 10 --output presentation.html
node <path-to-skill>/scripts/create-presentation.js --slides 10 --output presentation.html
Mixed structure: intro, 2 content slides, divider, 3-slide vertical stack, divider, closing
混合结构:介绍页、2张内容页、分隔页、3张幻灯片的垂直组、分隔页、结束页
node <path-to-skill>/scripts/create-presentation.js --structure 1,1,1,d,3,d,1 --title "Q4 Review" --output presentation.html
undefinednode <path-to-skill>/scripts/create-presentation.js --structure 1,1,1,d,3,d,1 --title "Q4 Review" --output presentation.html
undefinedStep 3: Customize the CSS
步骤3:自定义CSS
The scaffold script automatically copies to your presentation directory as . Now customize the CSS variables (especially colors) for your presentation theme.
base-styles.cssstyles.cssUsing Google Fonts: Add an at the top of your CSS file:
@importcss
@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@400;600;700&family=Lato:wght@300;400;600&display=swap');
:root {
--heading-font: "Playfair Display", Georgia, serif;
--body-font: "Lato", Helvetica, sans-serif;
/* ... */
}The base file includes:
- CSS Variables for easy customization:
css
:root {
/* ===========================================
BACKGROUND COLOR - Set this first!
=========================================== */
--background-color: #ffffff; /* Change for dark themes (e.g., #1a1a2e) */
/* Typography - ALWAYS use pt for font sizes */
--heading-font: "Source Sans Pro", Helvetica, sans-serif;
--body-font: "Source Sans Pro", Helvetica, sans-serif;
--base-font-size: 32px; /* Only px value - sets reveal.js base */
--text-size: 16pt; /* Base body text - intentionally small */
--h1-size: 48pt;
--h2-size: 36pt;
--h3-size: 24pt;
/* Colors - customize these for each presentation */
--primary-color: #2196F3;
--secondary-color: #ff9800;
--text-color: #222; /* Use light color (e.g., #FAF7F2) for dark backgrounds */
--muted-color: #666; /* Adjust for dark backgrounds too */
--box-bg: #f5f5f5;
--box-border: #ddd;
}- Override reveal.js styles using prefix:
.reveal
css
.reveal {
font-family: var(--body-font);
}
.reveal h1, .reveal h2, .reveal h3 {
font-family: var(--heading-font);
text-transform: none;
color: var(--text-color);
}
.reveal p, .reveal li {
font-size: var(--text-size);
color: var(--text-color);
}- Slide layout styles - control padding and positioning:
css
.reveal .slides section {
padding: 40px 60px;
text-align: left;
}-
Component classes - boxes, callouts, etc. (see CSS Components Reference)
-
Text size utilities (use these to scale up text when slides have less content):
css
/* Base text is 16pt - use these classes to increase size when needed */
.text-lg { font-size: 18pt; } /* Slightly larger */
.text-xl { font-size: 20pt; } /* Medium emphasis */
.text-2xl { font-size: 24pt; } /* Strong emphasis */
.text-3xl { font-size: 28pt; } /* Very large */
.text-4xl { font-size: 32pt; } /* Maximum body text */
.text-muted { color: var(--muted-color); }
.text-center { text-align: center; }Typography guidance:
- Base text () is intentionally small to fit more content
--text-size: 16pt - When a slide has less content, use ,
.text-lg, etc. to fill space appropriately.text-xl - This approach prevents overflow on content-heavy slides while allowing flexibility on lighter slides
框架脚本会自动将复制到你的演示文稿目录中并命名为。现在可以自定义CSS变量(尤其是颜色)来设置你的演示文稿主题。
base-styles.cssstyles.css使用Google Fonts:在CSS文件顶部添加:
@importcss
@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@400;600;700&family=Lato:wght@300;400;600&display=swap');
:root {
--heading-font: "Playfair Display", Georgia, serif;
--body-font: "Lato", Helvetica, sans-serif;
/* ... */
}基础文件包含:
- 便于自定义的CSS变量:
css
:root {
/* ===========================================
背景色 - 首先设置这个!
=========================================== */
--background-color: #ffffff; /* 深色主题可改为(如#1a1a2e) */
/* 排版 - 始终使用pt作为字体单位 */
--heading-font: "Source Sans Pro", Helvetica, sans-serif;
--body-font: "Source Sans Pro", Helvetica, sans-serif;
--base-font-size: 32px; /* 唯一的px值 - 设置reveal.js的基础字号 */
--text-size: 16pt; /* 基础正文文本 - 故意设置较小 */
--h1-size: 48pt;
--h2-size: 36pt;
--h3-size: 24pt;
/* 颜色 - 为每个演示文稿自定义这些值 */
--primary-color: #2196F3;
--secondary-color: #ff9800;
--text-color: #222; /* 深色背景下使用浅色(如#FAF7F2) */
--muted-color: #666; /* 深色背景下也要调整这个值 */
--box-bg: #f5f5f5;
--box-border: #ddd;
}- 使用.reveal前缀覆盖reveal.js样式:
css
.reveal {
font-family: var(--body-font);
}
.reveal h1, .reveal h2, .reveal h3 {
font-family: var(--heading-font);
text-transform: none;
color: var(--text-color);
}
.reveal p, .reveal li {
font-size: var(--text-size);
color: var(--text-color);
}- 幻灯片布局样式 - 控制内边距和定位:
css
.reveal .slides section {
padding: 40px 60px;
text-align: left;
}-
组件类 - 方框、提示框等(见CSS组件参考)
-
文本大小工具类(当幻灯片内容较少时,使用这些类放大文本):
css
/* 基础文本为16pt - 必要时使用这些类增大字号 */
.text-lg { font-size: 18pt; } /* 稍大 */
.text-xl { font-size: 20pt; } /* 中等强调 */
.text-2xl { font-size: 24pt; } /* 强强调 */
.text-3xl { font-size: 28pt; } /* 非常大 */
.text-4xl { font-size: 32pt; } /* 最大正文字号 */
.text-muted { color: var(--muted-color); }
.text-center { text-align: center; }排版指南:
- 基础文本()故意设置较小,以便容纳更多内容
--text-size: 16pt - 当幻灯片内容较少时,使用、
.text-lg等类来适当填充空间.text-xl - 这种方法可以避免内容较多的幻灯片溢出,同时在内容较少的幻灯片上提供灵活性
Step 4: Fill in the HTML Content
步骤4:填充HTML内容
Edit the generated HTML file to add content to each slide. Follow these patterns:
Standard slide structure:
html
<section id="unique-slide-id">
<h2>Slide Title</h2>
<div class="content">
<!-- Content here -->
</div>
</section>Multi-column layouts - always use inline CSS grid (do NOT create utility classes like ):
.grid-2html
<!-- Equal columns -->
<div style="display: grid; grid-template-columns: repeat(2, 1fr); gap: 30px;">
<div>Column 1</div>
<div>Column 2</div>
</div>
<!-- Three columns -->
<div style="display: grid; grid-template-columns: repeat(3, 1fr); gap: 25px;">
<div>Column 1</div>
<div>Column 2</div>
<div>Column 3</div>
</div>
<!-- Unequal columns -->
<div style="display: grid; grid-template-columns: 1fr 2fr; gap: 30px;">
<div>Narrow sidebar</div>
<div>Wide main content</div>
</div>Why inline styles for grids? Each slide's layout needs vary - column ratios, gaps, etc. Inline styles give you full control per-slide without creating dozens of utility classes.
Important HTML patterns:
- Every should have a unique
<section>attribute for stable identificationid - Use for centered section title slides
class="section-divider" - Wrap main content in for consistent spacing. This is a flexbox container that fills the remaining vertical space below the title, ensuring content flows properly.
<div class="content"> - Use for attribution or source text at bottom
<div class="footnote">
编辑生成的HTML文件,为每张幻灯片添加内容。遵循以下模式:
标准幻灯片结构:
html
<section id="unique-slide-id">
<h2>幻灯片标题</h2>
<div class="content">
<!-- 内容放在这里 -->
</div>
</section>多列布局 - 始终使用内联CSS Grid(不要创建这样的工具类):
.grid-2html
<!-- 等宽两列 -->
<div style="display: grid; grid-template-columns: repeat(2, 1fr); gap: 30px;">
<div>第一列</div>
<div>第二列</div>
</div>
<!-- 三列 -->
<div style="display: grid; grid-template-columns: repeat(3, 1fr); gap: 25px;">
<div>第一列</div>
<div>第二列</div>
<div>第三列</div>
</div>
<!-- 不等宽列 -->
<div style="display: grid; grid-template-columns: 1fr 2fr; gap: 30px;">
<div>窄侧边栏</div>
<div>宽主内容区</div>
</div>为什么网格要用内联样式?每张幻灯片的布局需求不同——列比例、间距等。内联样式让你可以针对每张幻灯片进行完全控制,而无需创建几十个工具类。
重要HTML模式:
- 每个都应该有唯一的
<section>属性,以便稳定识别id - 对于居中的章节标题幻灯片,使用
class="section-divider" - 将主要内容包裹在中,以保证一致的间距。这是一个flexbox容器,会填充标题下方剩余的垂直空间,确保内容正确排列。
<div class="content"> - 使用在底部添加署名或来源文本
<div class="footnote">
Step 5: Check for Content Overflow
步骤5:检查内容溢出
Run the overflow checker to ensure no slides have content that extends beyond boundaries:
bash
node scripts/check-overflow.js presentation.htmlThe script checks each slide for:
- Vertical overflow: Content taller than slide height
- Horizontal overflow: Content wider than slide width
If overflow is detected, reduce content or adjust font sizes on affected slides.
运行溢出检查器,确保没有幻灯片的内容超出边界:
bash
node scripts/check-overflow.js presentation.html该脚本会检查每张幻灯片的:
- 垂直溢出:内容高度超过幻灯片高度
- 水平溢出:内容宽度超过幻灯片宽度
如果检测到溢出,减少内容或调整受影响幻灯片的字号。
Step 6: Visual Review with Screenshots
步骤6:使用截图进行视觉审查
CRITICAL: You MUST review screenshots of EVERY SINGLE SLIDE. Do not skip slides or review only a sample. Visual issues are common and can only be caught by examining each slide individually.
Capture screenshots of all slides:
bash
cd <presentation-directory>
npx decktape reveal "presentation.html?export" output.pdf \
--screenshots \
--screenshots-directory "screenshots/$(date +%Y%m%d_%H%M%S)"Note: The query parameter disables chart animations for cleaner PDF rendering. Charts will still animate when viewing the HTML directly in a browser.
?exportThis creates a timestamped folder (e.g., ) so you can track versions and compare before/after fixes.
screenshots/20241210_143052/Then use the Read tool to examine each screenshot image file.
关键要求:你必须审查每一张幻灯片的截图。 不要跳过任何幻灯片或只审查样本。视觉问题很常见,只有逐一检查每张幻灯片才能发现。
捕获所有幻灯片的截图:
bash
cd <presentation-directory>
npx decktape reveal "presentation.html?export" output.pdf \
--screenshots \
--screenshots-directory "screenshots/$(date +%Y%m%d_%H%M%S)"注意:查询参数会禁用图表动画,以便生成更清晰的PDF。在浏览器中直接查看HTML时,图表仍然会有动画效果。
?export这会创建一个带时间戳的文件夹(例如),让你可以跟踪版本并比较修复前后的效果。
screenshots/20241210_143052/然后使用读取工具检查每个截图文件。
What to Look For
需要检查的内容
The overflow script catches most layout issues, but these problems require visual inspection:
-
Color inheritance in containers: Text inside boxes or callouts may inherit the wrong color from parent elements. If you have light text on a dark page background, text inside a light-coloredor
.boxwill be unreadable unless you explicitly set dark text color for that container..calloutFix pattern - explicitly set text and bullet colors for light containers:css.box-light p, .box-light li { color: var(--text-dark); } .box-light ul li::before { background: var(--primary-color); /* bullet color */ } -
Custom bullet/list styling: If you override default list styles, bullets may not contrast well on all container backgrounds.
-
Icons not rendering: If Font Awesome fails to load, you'll see empty squares or nothing where icons should be.
-
Overflow edge cases: The script catches most overflow, but complex nested layouts occasionally slip through.
-
Unexpected text wrap: Text that you expected to fit on one line actually overflows to two lines. This is especially common in column layouts, where the header of one column may wrap while the rest don't, making things uneven.
Re-capture specific slides after fixes:
bash
npx decktape reveal "presentation.html?export" output.pdf \
--screenshots \
--screenshots-directory "screenshots/$(date +%Y%m%d_%H%M%S)" \
--slides 2,5,7-9Then re-examine the updated screenshots to verify fixes. The new timestamped folder makes it easy to compare with the previous version.
溢出脚本可以捕获大多数布局问题,但以下问题需要视觉检查:
-
容器中的颜色继承:方框或提示框内的文本可能会从父元素继承错误的颜色。如果你在深色页面背景上使用浅色文本,那么浅色的或
.box内的文本会变得不可读,除非你为该容器显式设置深色文本颜色。.callout修复模式 - 为浅色容器显式设置文本和项目符号颜色:css.box-light p, .box-light li { color: var(--text-dark); } .box-light ul li::before { background: var(--primary-color); /* 项目符号颜色 */ } -
自定义项目符号/列表样式:如果你覆盖了默认列表样式,项目符号在所有容器背景上可能对比度不足。
-
图标未渲染:如果Font Awesome加载失败,图标位置会显示空方块或空白。
-
溢出边缘情况:脚本可以捕获大多数溢出,但复杂的嵌套布局偶尔会被漏掉。
-
意外文本换行:你原本以为可以放在一行的文本实际上会换行到第二行。这种情况在多列布局中尤其常见,其中一列的标题可能会换行,而其他列不会,导致布局不均匀。
修复后重新捕获特定幻灯片:
bash
npx decktape reveal "presentation.html?export" output.pdf \
--screenshots \
--screenshots-directory "screenshots/$(date +%Y%m%d_%H%M%S)" \
--slides 2,5,7-9然后重新检查更新后的截图,验证修复效果。新的带时间戳的文件夹让你可以轻松与之前的版本进行比较。
CSS Components Reference
CSS组件参考
Boxes
方框
css
.box {
background: var(--box-bg);
border: 1px solid var(--box-border);
border-radius: 8px;
padding: 20px;
}
.box-outlined {
border: 1px solid var(--box-border);
border-radius: 8px;
padding: 20px;
background: transparent;
}css
.box {
background: var(--box-bg);
border: 1px solid var(--box-border);
border-radius: 8px;
padding: 20px;
}
.box-outlined {
border: 1px solid var(--box-border);
border-radius: 8px;
padding: 20px;
background: transparent;
}Callouts
提示框
css
.callout {
border-left: 6px solid var(--primary-color);
padding: 15px 20px;
margin: 15px 0;
background: #f9f9f9;
border-radius: 8px;
}
/* Color variants */
.callout-blue { border-left-color: #2196F3; background: #e3f2fd; }
.callout-orange { border-left-color: #ff9800; background: #fff3e0; }
.callout-green { border-left-color: #4caf50; background: #e8f5e9; }
.callout-gray { border-left-color: #666; background: #f5f5f5; }css
.callout {
border-left: 6px solid var(--primary-color);
padding: 15px 20px;
margin: 15px 0;
background: #f9f9f9;
border-radius: 8px;
}
/* 颜色变体 */
.callout-blue { border-left-color: #2196F3; background: #e3f2fd; }
.callout-orange { border-left-color: #ff9800; background: #fff3e0; }
.callout-green { border-left-color: #4caf50; background: #e8f5e9; }
.callout-gray { border-left-color: #666; background: #f5f5f5; }Blockquotes
引用块
css
.reveal blockquote {
border-left: 4px solid var(--primary-color);
padding-left: 20px;
margin: 20px 0;
font-style: italic;
background: none;
box-shadow: none;
width: 100%;
}
.reveal blockquote cite {
display: block;
margin-top: 10px;
font-style: normal;
color: var(--muted-color);
}css
.reveal blockquote {
border-left: 4px solid var(--primary-color);
padding-left: 20px;
margin: 20px 0;
font-style: italic;
background: none;
box-shadow: none;
width: 100%;
}
.reveal blockquote cite {
display: block;
margin-top: 10px;
font-style: normal;
color: var(--muted-color);
}Icons (Font Awesome)
图标(Font Awesome)
Font Awesome is included in the scaffold. Usage:
html
<i class="fa-solid fa-lightbulb"></i>
<i class="fa-solid fa-check"></i>
<i class="fa-solid fa-gears"></i>基础框架中已包含Font Awesome。使用方法:
html
<i class="fa-solid fa-lightbulb"></i>
<i class="fa-solid fa-check"></i>
<i class="fa-solid fa-gears"></i>Advanced Features
高级功能
For fragments (progressive reveal), speaker notes, custom backgrounds, auto-animate, and transitions, see references/advanced-features.md.
关于片段(渐进式显示)、演讲者备注、自定义背景、自动动画和过渡效果,请参阅references/advanced-features.md。
Reveal.js Configuration
Reveal.js 配置
javascript
Reveal.initialize({
controls: true, // Show navigation arrows
progress: true, // Show progress bar
slideNumber: true, // Show slide numbers
hash: true, // Update URL hash for each slide
transition: 'slide', // none/fade/slide/convex/concave/zoom
center: false, // Vertical centering of slide content
autoSlide: 0, // Auto-advance (ms), 0 to disable
loop: false, // Loop presentation
});Note on : Default is (content aligns to top), which works best for content-heavy slides. Set to for minimal/creative presentations where you want content vertically centered.
centerfalsetruejavascript
Reveal.initialize({
controls: true, // 显示导航箭头
progress: true, // 显示进度条
slideNumber: true, // 显示幻灯片编号
hash: true, // 为每张幻灯片更新URL哈希
transition: 'slide', // none/fade/slide/convex/concave/zoom
center: false, // 幻灯片内容垂直居中
autoSlide: 0, // 自动翻页(毫秒),0表示禁用
loop: false, // 循环播放演示文稿
});关于的说明:默认值为(内容顶部对齐),这最适合内容较多的幻灯片。对于极简/创意演示文稿,如果你希望内容垂直居中,可以设置为。
centerfalsetrueBuilt-in Reveal.js Classes
内置Reveal.js类
Use these directly without custom CSS:
- - Auto-size text to fill slide
r-fit-text - - Stretch element to fill remaining vertical space
r-stretch - - Layer elements on top of each other
r-stack
html
<h1 class="r-fit-text">BIG TEXT</h1>
<img class="r-stretch" src="image.jpg">无需自定义CSS,可直接使用这些类:
- - 自动调整文本大小以填满幻灯片
r-fit-text - - 拉伸元素以填充剩余垂直空间
r-stretch - - 将元素层叠在一起
r-stack
html
<h1 class="r-fit-text">大文本</h1>
<img class="r-stretch" src="image.jpg">Adding Charts
添加图表
IMPORTANT: Before adding ANY chart, you MUST read references/charts.md. Charts require specific flexbox/grid patterns to size correctly and avoid overflow. Do not attempt to add charts without reading the full documentation first.
The scaffold includes the Chart.js plugin for adding bar, line, pie, doughnut, and scatter charts to slides.
Required pattern - charts need flexbox containers and :
maintainAspectRatio: falsehtml
<section style="display: flex; flex-direction: column; height: 100%;">
<h2>Chart Title</h2>
<div style="flex: 1; position: relative; min-height: 0;">
<canvas data-chart="bar">
<!--
{
"data": {
"labels": ["Q1", "Q2", "Q3", "Q4"],
"datasets": [{ "label": "Revenue", "data": [12, 19, 8, 15] }]
},
"options": {
"maintainAspectRatio": false
}
}
-->
</canvas>
</div>
</section>references/charts.md covers (required reading):
- Layout patterns: full slide, half (horizontal/vertical), quarter, unequal splits (1fr 2fr, 1fr 3fr)
- Why the flexbox pattern is required (Chart.js aspect ratio behavior)
- All chart types (bar, line, pie, doughnut, scatter, etc.)
- Styling and color options
- CSV data format (simpler alternative to JSON)
重要提示:在添加任何图表之前,你必须阅读references/charts.md。 图表需要特定的flexbox/grid模式才能正确调整大小并避免溢出。在未阅读完整文档之前,不要尝试添加图表。
基础框架包含Chart.js插件,可在幻灯片中添加柱状图、折线图、饼图、环形图和散点图。
必填模式 - 图表需要flexbox容器和:
maintainAspectRatio: falsehtml
<section style="display: flex; flex-direction: column; height: 100%;">
<h2>图表标题</h2>
<div style="flex: 1; position: relative; min-height: 0;">
<canvas data-chart="bar">
<!--
{
"data": {
"labels": ["Q1", "Q2", "Q3", "Q4"],
"datasets": [{ "label": "收入", "data": [12, 19, 8, 15] }]
},
"options": {
"maintainAspectRatio": false
}
}
-->
</canvas>
</div>
</section>references/charts.md涵盖(必读内容):
- 布局模式:全屏、半屏(水平/垂直)、四分之一屏、不等分(1fr 2fr、1fr 3fr)
- 为什么需要flexbox模式(Chart.js的宽高比行为)
- 所有图表类型(柱状图、折线图、饼图、环形图、散点图等)
- 样式和颜色选项
- CSV数据格式(比JSON更简单的替代方案)
Dependencies
依赖项
Required for the scripts, should be already installed:
- Node.js (for running scripts)
- Puppeteer (for overflow checking):
npm install puppeteer - Decktape (for screenshots): (runs directly)
npx decktape
运行脚本所需的依赖项,应该已经安装:
- Node.js(用于运行脚本)
- Puppeteer(用于溢出检查):
npm install puppeteer - Decktape(用于截图):(直接运行)
npx decktape