实现html播放ppt的炫酷效果

是国外程序员的开源js库,我做了一个简单的ppt放在网上,下面是使用教程,原文是英文的,下面是我翻译的哦。 首先看一下演示效果:演示地址

源代码下载

<!doctype html>  

<html lang="en">

<head>  
    <meta charset="utf-8">  

    <title>reveal.js - The HTML Presentation Framework</title>  

    <meta name="description" content="A framework for easily creating beautiful presentations using HTML">  
    <meta name="author" content="Hakim El Hattab">  

    <meta name="apple-mobile-web-app-capable" content="yes" />  
    <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />  

    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, minimal-ui">  

    <link rel="stylesheet" href="css/reveal.css">  
    <link rel="stylesheet" href="css/theme/black.css" id="theme">  

    <!-- Code syntax highlighting -->
    <link rel="stylesheet" href="lib/css/zenburn.css">  

    <!-- Printing and PDF exports -->
    <script>  
        var link = document.createElement( 'link' );  
        link.rel = 'stylesheet';  
        link.type = 'text/css';  
        link.href = window.location.search.match( /print-pdf/gi ) ? 'css/print/pdf.css' : 'css/print/paper.css';  
        document.getElementsByTagName( 'head' )[0].appendChild( link );  
    </script>  

    <!--[if lt IE 9]>  
    <script src="lib/js/html5shiv.js"></script>  
    <![endif]-->
</head>  

<body>  

    <div class="reveal">  

        <!-- Any section element inside of this container is displayed as a slide -->
        <div class="slides">  
            <section>  
                <h1>Reveal.js</h1>  
                <h3>HTML展现ppt效果的框架</h3>  
                <p>  
                    <small>Created by <a href="http://hakim.se">Hakim El Hattab</a> / <a href="http://twitter.com/hakimel">@hakimel</a></small>  
                </p>  
            </section>  

            <section>  
                <h2>概述</h2>  
                <p>  
                    reveal.js 能让你用HTML构建漂亮的交互式幻灯片。这个页面将会告诉你怎么做!  

                </p>  
            </section>  

            <!-- Example of nested vertical slides -->
            <section>  
                <section>  
                    <h2>垂直幻灯片</h2>  
                    <p>幻灯片可以相互嵌套</p>  
                    <p>用 <em>space</em> 键播放幻灯片 </p>  

                    <a href="#" class="navigate-down">  
                        <img width="178" height="238" data-src="https://s3.amazonaws.com/hakim-static/reveal-js/arrow.png" alt="Down arrow">  
                    </a>  
                </section>  
                <section>  
                    <h2>地下1层</h2>  
                    <p>   嵌套幻灯片可以添加额外的详细信息,下面是有用的高水平下滑 </p>  
                </section>  
                <section>  
                    <h2>地下2层</h2>  
                    <p>现在,是时候往上了</p>  

                    <a href="#/2">  
                        <img width="178" height="238" data-src="https://s3.amazonaws.com/hakim-static/reveal-js/arrow.png" alt="Up arrow" style="transform: rotate(180deg); -webkit-transform: rotate(180deg);">  
                    </a>  
                </section>  
            </section>  

            <section>  
                <h2>幻灯片</h2>  
                <p>  
                    不是程序员?  没关系,这里有可视化界面编辑的网站 <a href="http://slides.com" target="_blank">http://slides.com</a>.  
                </p>  
            </section>  

            <section>  
                <h2>视图焦点</h2>  
                <p>  
                    点击 <strong>ESC</strong> 可以查看幻灯片的综述  
                </p>  
                <p>  
                    按住 Alt 不放,单击鼠标左键到屏幕 <a href="http://lab.hakim.se/zoom-js">这里</a>。Alt +  单击鼠标左键到屏幕任意位置返回。  
                </p>  
            </section>  

            <section>  
                <h2>触摸优化</h2>  
                <p>  
                    ppt在触摸设备上看起来效果很好,比如手机和平板电脑。简单的滑动幻灯片。  
                </p>  
            </section>  

            <section data-markdown>  
                <script type="text/template">  
                    ## Markdown 支持  

                    使用内部或外部Markdown编辑内容。在 [readme](https://github.com/hakimel/reveal.js#markdown)查看更多信息。  

                    ```  
                    <section data-markdown>  
                      ## Markdown support  

                      Write content using inline or external Markdown.  
                      Instructions and more info available in the [readme](https://github.com/hakimel/reveal.js#markdown).  
                    </section>  
                    ```  
                </script>  
            </section>  

            <section>  
                <section id="fragments">  
                    <h2>Fragments</h2>  
                    <p>点击下一个箭头...</p>  
                    <p class="fragment">... 下一步 ...</p>  
                    <p><span class="fragment">... a</span> <span class="fragment">fragmented</span> <span class="fragment">slide.</span></p>  

                    <aside class="notes">  
                        This slide has fragments which are also stepped through in the notes window.  
                    </aside>  
                </section>  
                <section>  
                    <h2>Fragment 样式</h2>  
                    <p>有许多不同样式的 fragments, 比如:</p>  
                    <p class="fragment grow">grow</p>  
                    <p class="fragment shrink">shrink</p>  
                    <p class="fragment fade-out">fade-out</p>  
                    <p class="fragment current-visible">current-visible</p>  
                    <p class="fragment highlight-red">highlight-red</p>  
                    <p class="fragment highlight-blue">highlight-blue</p>  
                </section>  
            </section>  

            <section id="transitions">  
                <h2>过渡样式</h2>  
                <p>  
                    你可以选择不同的过渡样式, 比如:   
                    <a href="?transition=none#/transitions">None</a> -  
                    <a href="?transition=fade#/transitions">Fade</a> -  
                    <a href="?transition=slide#/transitions">Slide</a> -  
                    <a href="?transition=convex#/transitions">Convex</a> -  
                    <a href="?transition=concave#/transitions">Concave</a> -  
                    <a href="?transition=zoom#/transitions">Zoom</a>  
                </p>  
            </section>  

            <section id="themes">  
                <h2>主题</h2>  
                <p>  
                    reveal.js 有如下主题可选:   

<!-- Hacks to swap themes after the page has loaded. Not flexible and only intended for the reveal.js demo deck. --> Black (default) -
White -
League -
Sky -
Beige -
Simple
Serif -
Blood -
Night -
Moon -
Solarized


            <section>  
                <section data-background="#dddddd">  
                    <h2>背景</h2>  
                    <p>  
                        设置 <code>data-background="#dddddd"</code> 改变ppt的背景颜色. 所有CSS颜色标签都支持。  
                    </p>  
                    <a href="#" class="navigate-down">  
                        <img width="178" height="238" data-src="https://s3.amazonaws.com/hakim-static/reveal-js/arrow.png" alt="Down arrow">  
                    </a>  
                </section>  
                <section data-background="https://s3.amazonaws.com/hakim-static/reveal-js/image-placeholder.png">  
                    <h2>图片背景</h2>  
                    <pre><code class="hljs"><section data-background="image.png"></code></pre>  
                </section>  
                <section data-background="https://s3.amazonaws.com/hakim-static/reveal-js/image-placeholder.png" data-background-repeat="repeat" data-background-size="100px">  
                    <h2>平铺的图片背景</h2>  
                    <pre><code class="hljs" style="word-wrap: break-word;"><section data-background="image.png" data-background-repeat="repeat" data-background-size="100px"></code></pre>  
                </section>  
                <section data-background-video="https://s3.amazonaws.com/static.slid.es/site/homepage/v1/homepage-video-editor.mp4,https://s3.amazonaws.com/static.slid.es/site/homepage/v1/homepage-video-editor.webm" data-background-color="#000000">  
                    <div style="background-color: rgba(0, 0, 0, 0.9); color: #fff; padding: 20px;">  
                        <h2>视频背景</h2>  
                        <pre><code class="hljs" style="word-wrap: break-word;"><section data-background-video="video.mp4,video.webm"></code></pre>  
                    </div>  
                </section>  
                <section data-background="http://i.giphy.com/90F8aUepslB84.gif">  
                    <h2>GIF图片背景!</h2>  
                </section>  
            </section>  

            <section data-transition="slide" data-background="#4d7e65" data-background-transition="zoom">  
                <h2>背景过渡</h2>  
                <p>  
                    可以选择不同的背景过渡,下面这种是 "zoom".  
                </p>  
                <pre><code class="hljs">Reveal.configure({ backgroundTransition: 'zoom' })</code></pre>  
            </section>  

            <section data-transition="slide" data-background="#b5533c" data-background-transition="zoom">  
                <h2>背景过渡</h2>  
                <p>  
                    你可以给每一页ppt设置不同的背景过渡.  
                </p>  
                <pre><code class="hljs" style="word-wrap: break-word;"><section data-background-transition="zoom"></code></pre>  
            </section>  

            <section>  
                <h2>漂亮的代码样式</h2>  
                <pre><code class="hljs" data-trim contenteditable>  

function linkify( selector ) {
if( supports3DTransforms ) {

var nodes = document.querySelectorAll( selector );

for( var i = 0, len = nodes.length; i < len; i++ ) {
var node = nodes;

if( !node.className ) {
node.className += ' roll';
}
}
}
}

语法高亮的代码highlight.js.


            <section>  
                <h2>无序列表</h2>  
                <ul>  
                    <li>No order here</li>  
                    <li>Or here</li>  
                    <li>Or here</li>  
                    <li>Or here</li>  
                </ul>  
            </section>  

            <section>  
                <h2>有序列表</h2>  
                <ol>  
                    <li>One is smaller than...</li>  
                    <li>Two is smaller than...</li>  
                    <li>Three!</li>  
                </ol>  
            </section>  

            <section>  
                <h2>表格</h2>  
                <table>  
                    <thead>  
                        <tr>  
                            <th>物品</th>  
                            <th>价格</th>  
                            <th>数量</th>  
                        </tr>  
                    </thead>  
                    <tbody>  
                        <tr>  
                            <td>苹果</td>  
                            <td>$1</td>  
                            <td>7</td>  
                        </tr>  
                        <tr>  
                            <td>柠檬</td>  
                            <td>$2</td>  
                            <td>18</td>  
                        </tr>  
                        <tr>  
                            <td>面包</td>  
                            <td>$3</td>  
                            <td>2</td>  
                        </tr>  
                    </tbody>  
                </table>  
            </section>  

            <section>  
                <h2>引用</h2>  
                <p>  
                    有两种形式的引用, 内联的: <q cite="http://searchservervirtualization.techtarget.com/definition/Our-Favorite-Technology-Quotations">  
                    “The nice thing about standards is that there are so many to choose from”</q>  
                </p>和成块的引用:  
                <blockquote cite="http://searchservervirtualization.techtarget.com/definition/Our-Favorite-Technology-Quotations">  
                    “For years there has been a theory that millions of monkeys typing at random on millions of typewriters would   reproduce the entire works of Shakespeare. The Internet has proven this theory to be untrue.”  
                </blockquote>  
            </section>  

            <section>  
                <h2>链接跳转</h2>  
                <p>  
                    你可以链接跳转到ppt内部的某一页,  
                    <a href="#/2/3">点击这里</a>.  
                </p>  
            </section>  

            <section>  
                <h2>演讲者模式</h2>  
                <p>这里有一种<a href="https://github.com/hakimel/reveal.js#speaker-notes">演讲者模式</a>. 它包括计时器, 预览即将到来的下一页ppt或者笔记.</p>  
                <p>按住 <em>s</em> 试一试.</p>  

                <aside class="notes">  
                    Oh hey, these are some notes. They'll be hidden in your presentation, but you can see them if you open the speaker notes window (hit 's' on your keyboard).  
                </aside>  
            </section>  

            <section>  
                <h2>输出pdf</h2>  
                <p>可以输出 <a href="https://github.com/hakimel/reveal.js#pdf-export">PDF</a>,下面是例子:</p>  
                <iframe src="https://www.slideshare.net/slideshow/embed_code/42840540" width="445" height="355" frameborder="0" marginwidth="0" marginheight="0" scrolling="no" style="border:3px solid #666; margin-bottom:5px; max-width: 100%;" allowfullscreen> </iframe>  
            </section>  

            <section>  
                <h2>全局状态</h2>  
                <p>  
                    设置 <code>data-state="something"</code> 在ppt上 <code>"something"</code>  
                    会在ppt打开的时候作为一个class加到每一个文件元素里.    
                </p>  
            </section>  

            <section data-state="customevent">  
                <h2>状态事件</h2>  
                <p>  
                 另外可以触发自定义事件绑定在每张幻灯片的上的 <code>data-state</code> 值.  
                </p>  
                <pre><code class="javascript" data-trim contenteditable style="font-size: 18px;">  

Reveal.addEventListener( 'customevent', function() {
console.log( '"customevent" has fired' );
} );

            <section>  
                <h2>花点时间</h2>  
                <p>  
                    点击 B 或者 . 暂停演示.   
                </p>  
            </section>  

            <section>  
                <h2>更多支持</h2>  
                <ul>                        
                    <li><a href="https://github.com/hakimel/reveal.js#api">Extensive JavaScript API</a></li>  
                    <li><a href="https://github.com/hakimel/reveal.js#auto-sliding">自动播放</a></li>  
                    <li><a href="https://github.com/hakimel/reveal.js#parallax-background">Parallax backgrounds</a></li>  
                    <li><a href="https://github.com/hakimel/reveal.js#keyboard-bindings">自定义键盘绑定</a></li>  
                </ul>  
            </section>  

            <section style="text-align: left;">  
                <h1>结束</h1>  
                <p>  
                    - <a href="http://slides.com">试试在线编辑器</a>   
                    - <a href="https://github.com/hakimel/reveal.js">源代码 & 文件</a>  
                </p>  
            </section>  

        </div>  

    </div>  

    <script src="lib/js/head.min.js"></script>  
    <script src="js/reveal.js"></script>  

    <script>  

        // Full list of configuration options available at:  
        // https://github.com/hakimel/reveal.js#configuration  
        Reveal.initialize({  
            controls: true,  
            progress: true,  
            history: true,  
            center: true,  

            transition: 'slide', // none/fade/slide/convex/concave/zoom  

            // Optional reveal.js plugins  
            dependencies: [  
                { src: 'lib/js/classList.js', condition: function() { return !document.body.classList; } },  
                { src: 'plugin/markdown/marked.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },  
                { src: 'plugin/markdown/markdown.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },  
                { src: 'plugin/highlight/highlight.js', async: true, condition: function() { return !!document.querySelector( 'pre code' ); }, callback: function() { hljs.initHighlightingOnLoad(); } },  
                { src: 'plugin/zoom-js/zoom.js', async: true },  
                { src: 'plugin/notes/notes.js', async: true }  
            ]  
        });  

    </script>  

</body>  

</html>

源代码下载

收藏 1 分享浏览 2503
1年前
跟帖
沙发
王坚janking
1年前

加油 加油 这个不错

板凳
王坚janking
1年前

赞了此话题!

地板
呆呆的学习者
5个月前

赞了此话题!

4 楼
说几句
广告位 点击查看投放指南

我的收藏