深圳专业网站建设制作价格,北京软件外包公司排名,中国域名注册中心,网站推广合同模板Reveal.js 中文使用教程
Reveal.js 是一个功能强大的开源 HTML 演示文稿框架#xff0c;使用纯 HTML、CSS 和 JavaScript 即可创建专业、美观的幻灯片。本教程基于官方 demo.html 源码分析#xff0c;系统介绍 Reveal.js 的使用方法和核心功能。
一、基础结构
1.1 HTML 基…Reveal.js 中文使用教程Reveal.js 是一个功能强大的开源 HTML 演示文稿框架使用纯 HTML、CSS 和 JavaScript 即可创建专业、美观的幻灯片。本教程基于官方demo.html源码分析系统介绍 Reveal.js 的使用方法和核心功能。一、基础结构1.1 HTML 基本框架!DOCTYPEhtmlhtmllangzhheadmetacharsetutf-8metanameviewportcontentwidthdevice-width, initial-scale1.0, maximum-scale1.0, user-scalablenotitleReveal.js 演示文稿/title!-- 核心样式 --linkrelstylesheethrefdist/reveal.css!-- 主题样式可替换 --linkrelstylesheethrefdist/theme/black.css/headbodydivclassrevealdivclassslides!-- 幻灯片内容 --section第一页/sectionsection第二页/section/div/div!-- 核心脚本 --scriptsrcdist/reveal.js/scriptscriptReveal.initialize({// 配置选项});/script/body/html1.2 核心文件结构dist/reveal.css核心样式dist/reveal.js核心脚本dist/theme/内置主题文件如 black.css、white.css 等plugin/插件目录如 highlight、markdown 等二、幻灯片布局2.1 水平幻灯片每个顶层section代表一张水平幻灯片左右切换divclassslidessection第 1 页/sectionsection第 2 页/sectionsection第 3 页/section/div2.2 垂直幻灯片在section中嵌套section可创建垂直幻灯片上下切换sectionsection垂直页 1/sectionsection垂直页 2/sectionsection垂直页 3/section/section2.3 混合布局示例divclassslidessection封面页/sectionsectionsection主题一概述/sectionsection主题一细节 1/sectionsection主题一细节 2/section/sectionsectionsection主题二概述/sectionsection主题二细节 1/section/sectionsection结束页/section/div三、主题与样式3.1 内置主题在head中引入不同主题文件black.css黑色主题white.css白色主题默认league.css灰色渐变beige.css米色sky.css蓝色天空night.css深蓝夜晚linkrelstylesheethrefdist/theme/white.css3.2 自定义背景sectiondata-background-color#ff0000纯色背景/sectionsectiondata-background-imageimage.jpg图片背景/sectionsectiondata-background-videovideo.mp4data-background-video-loopdata-background-video-muted视频背景/sectionsectiondata-background-iframehttps://example.com嵌入网页背景/section!-- 高级背景设置 --sectiondata-background-imageimage.jpgdata-background-sizecontaindata-background-positioncenter内容/section四、转场动画4.1 全局配置Reveal.initialize({transition:slide,// none | fade | slide | convex | concave | zoombackgroundTransition:fade// 背景转场});4.2 单页自定义sectiondata-transitionzoom缩放转场/sectionsectiondata-transitionfade淡入淡出/section五、内容元素5.1 标题与文本sectionh1一级标题/h1h2二级标题/h2p段落文本/psmall小字说明/small/section5.2 列表ulli无序列表项 1/lili无序列表项 2/li/ulolli有序列表项 1/lili有序列表项 2/li/ol5.3 图片imgsrcimage.pngalt描述!-- 无边框无阴影 --imgsrcimage.pngstyleborder:none;box-shadow:none;5.4 表格tabletheadtrth表头1/thth表头2/th/tr/theadtbodytrtd数据1/tdtd数据2/td/tr/tbody/table5.5 引用blockquotecite来源“这是引用文字”footer— 作者/footer/blockquote5.6 代码高亮precodeclasshljs javascriptfunction hello() { console.log(Hello Reveal.js!); }/code/pre六、高级功能6.1 Markdown 支持sectiondata-markdowntextareadata-template## Markdown 标题 - 列表项 - 列表项 javascript console.log(代码);引用6.2 自动动画Auto-Animatesectiondata-auto-animateh1标题/h1/sectionsectiondata-auto-animateh1stylecolor:red;font-size:3em;标题变大变红/h1/section6.3 代码逐步高亮precodeclasshljs javascriptdata-line-numbers1-2|4|6-8function example() { const a 1; const b 2; // 跳过 const c a b; return c * 2; }/code/pre6.4 嵌入网页iframesrchttps://example.comwidth100%height600/iframe七、插件系统7.1 常用插件配置Reveal.initialize({plugins:[RevealZoom,RevealNotes,RevealSearch,RevealMarkdown,RevealHighlight]});7.2 演讲者备注sectionh2幻灯片内容/h2asideclassnotes这是演讲者备注按 S 键打开演讲者视图/aside/section八、常用初始化配置Reveal.initialize({controls:true,progress:true,slideNumber:true,history:true,center:true,transition:slide,plugins:[RevealHighlight]});九、JavaScript API9.1 导航控制Reveal.next();// 下一页Reveal.prev();// 上一页Reveal.slide(2,1);// 跳转到第 3 个水平页的第 2 个垂直页9.2 事件监听Reveal.on(slidechanged,event{console.log(当前页,event.indexh,event.indexv);});十、实用技巧10.1 导出 PDF在 URL 后添加?print-pdf然后使用浏览器打印功能保存为 PDF。10.2 添加固定 Logoimgsrclogo.pngclassslide-logostyleposition:fixed;bottom:20px;right:20px;z-index:30;10.3 懒加载图片imgdata-srclarge-image.jpgalt懒加载十一、常用快捷键按键功能→ / 空格下一页←上一页↓ / ↑垂直方向切换Esc概览模式S演讲者视图F全屏B 或 .黑屏十二、快速开始模板!DOCTYPEhtmlhtmllangzhheadmetacharsetutf-8title我的 Reveal.js 演示/titlelinkrelstylesheethrefdist/reveal.csslinkrelstylesheethrefdist/theme/white.csslinkrelstylesheethrefplugin/highlight/monokai.css/headbodydivclassrevealdivclassslidessectionh1标题/h1p作者 / 日期/p/sectionsectionh2内容页/h2p这里写内容/p/sectionsectionh1谢谢观看/h1pQA/p/section/div/divscriptsrcdist/reveal.js/scriptscriptsrcplugin/highlight/highlight.js/scriptscriptReveal.initialize({controls:true,progress:true,center:true,transition:slide,plugins:[RevealHighlight]});/script/body/htmlReveal.js 通过简洁的 HTML 结构即可实现专业级演示效果。建议从官方demo.html开始实践逐步掌握嵌套布局、动画、插件等特性即可创建出丰富交互的幻灯片。