<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
    <title>圣诞主题</title>
    <link rel='stylesheet' href='common.css' />
    <script src="http://libs.baidu.com/jquery/1.9.1/jquery.js"></script>
    <script src="christmas.js"></script>
</head>
<body>
    <section class="container">
        <!-- 第一幅画面 -->
        <section class="page-a bg-adaptive">
        </section>
        <!-- 第二幅画面 -->
        <section class="page-b bg-adaptive">
        </section>
        <!-- 第三幅画面 -->
        <section class="page-c bg-adaptive">
        </section>
    </section>
    <button>点击播放音乐</button>
    <button>点击播放循环音乐</button>
    <script type="text/javascript">
    /**
     * 自适应页面大小
     * @param  {[type]} doc [description]
     * @param  {[type]} win [description]
     * @return {[type]}     [description]
     */
    var docEl = document.documentElement,
        resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize',
        recalc = function() {
            //自适应设置容器高度
            var container = document.querySelector(".container")
                //原始比例
            var proportion = 900 / 1440;
            container.style.height = container.clientWidth * proportion + "px";
        };
    window.addEventListener(resizeEvt, recalc, false);
    document.addEventListener('DOMContentLoaded', recalc, false);
    </script>
</body>
</html>
                    /**
 * 慕课网特制
 * 圣诞主题效果
 * @type {Object}
 */
/**
 * 背景音乐
 * @param {[type]} url  [description]
 * @param {[type]} loop [description]
 */
function HTML5Audio(url, loop) {
    var audio = new Audio(url);
    audio.autoplay = true;
    audio.loop = loop || false; //是否循环
    audio.play();
    return {
        end: function(callback) {
            audio.addEventListener('ended', function() {
                callback()
            }, false);
        }
    }
}
$(function() {
    $("button:first").click(function() {
        //背景音乐
        var audio1 = HTML5Audio('http://www.imooc.com/upload/media/one.mp3')
        audio1.end(function() {
            alert("音乐结束")
        })
    })
    $("button:last").click(function() {
        //循环播放那
        // ? url = http://www.imooc.com/upload/media/two.mp3'
    })
})
                    *{
    margin: 0;
    padding: 0;
}
/*body{
    width: 100%;
    height: 100%;
}*/
.container {
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
}
.bg-adaptive {
    background-size: 100% 100%;
} 
.container .page-a {
    width  : 100%;
    height : 100%;
    background-image: url("http://img1.sycdn.imooc.com//565d07770001790814410901.png");
    position: absolute;
    z-index: 5;
}
.container .page-b {
    width  : 100%;
    height : 100%;
    background-image: url("http://img1.sycdn.imooc.com//565d09fa000145a614410901.png");
    position: absolute;
    z-index: 4;
}
.page-c {
    width  : 100%;
    height : 100%;
    background-image: url("http://img1.sycdn.imooc.com//565d0b280001788014410901.png");
    position: absolute;
    z-index: 3;
}
/**
 * 页面切换
 * 镜头方法
 */
.effect-out{
    -webkit-animation: effectOut 8s ease-in-out forwards;
    -webkit-transform-origin:71% 72%;
    -moz-animation: effectOut 8s ease-in-out forwards;
    -moz-transform-origin:71% 72%;
}
@-webkit-keyframes effectOut{
    0% { opacity:1; }
    100% { -webkit-transform: scale(20); opacity:0; }
}
@-moz-keyframes effectOut{
    0% { opacity:1; }
    100% { -moz-transform: scale(20); opacity:0; }
}
.effect-in{
    z-index: 15;
    display: block;
    opacity:0;
    -webkit-transform: scale(8); 
    -webkit-animation: effectIn 5s ease-in-out forwards;
    -webkit-transform-origin:58.5% 73.5%;
    -moz-transform: scale(8); 
    -moz-animation: effectIn 5s ease-in-out forwards;
    -moz-transform-origin:58.5% 73.5%;
}
@-webkit-keyframes effectIn{
    100% { -webkit-transform: scale(1); opacity:1; }
}
@-moz-keyframes effectIn{
    100% { -moz-transform: scale(1); opacity:1; }
}