以下是 html5点击左侧导航动画切换页面代码 的示例演示效果:
部分效果截图:
HTML代码(index.html):
<!doctype html>
<html lang="en" class="no-js">
<head>
<meta charset="gb2312">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href='http://fonts.useso.com/css?family=PT+Sans:400,700' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="css/reset.css"> <!-- CSS reset -->
<link rel="stylesheet" href="css/style.css"> <!-- Resource style -->
<script src="js/modernizr.js"></script> <!-- Modernizr -->
<title>html5点击左侧导航动画切换页面</title>
</head>
<body>
<nav class="cd-side-navigation">
<ul>
<li>
<a href="#0" class="selected" data-menu="index">
<svg class="nc-icon outline" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="24px" height="24px" viewBox="0 0 24 24"><g transform="translate(0, 0)"> <polygon fill="none" stroke="#4a5261" stroke-width="2" stroke-linecap="square" stroke-miterlimit="10" points="12,2 3,10 3,23 9,23 9,16 15,16 15,23 21,23 21,10 " stroke-linejoin="miter"></polygon> </g></svg>
Intro
</a>
</li>
<li>
<a href="#0" data-menu="services">
<svg class="nc-icon outline" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="24px" height="24px" viewBox="0 0 24 24"><g transform="translate(0, 0)"> <polyline data-color="color-2" fill="none" stroke="#4a5261" stroke-width="2" stroke-linecap="square" stroke-miterlimit="10" points=" 16,7 16,2 8,2 8,7 " stroke-linejoin="miter"></polyline> <rect x="1" y="7" fill="none" stroke="#4a5261" stroke-width="2" stroke-linecap="square" stroke-miterlimit="10" width="22" height="15" stroke-linejoin="miter"></rect> <line fill="none" stroke="#4a5261" stroke-width="2" stroke-linecap="square" stroke-miterlimit="10" x1="5" y1="7" x2="5" y2="22" stroke-linejoin="miter"></line> <line fill="none" stroke="#4a5261" stroke-width="2" stroke-linecap="square" stroke-miterlimit="10" x1="19" y1="7" x2="19" y2="22" stroke-linejoin="miter"></line> </g></svg>
Services
</a>
</li>
<li>
<a href="#0" data-menu="projects">
<svg class="nc-icon outline" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="24px" height="24px" viewBox="0 0 24 24"><g transform="translate(0, 0)"> <rect x="1" y="1" fill="none" stroke="#4a5261" stroke-width="2" stroke-linecap="square" stroke-miterlimit="10" width="22" height="22" stroke-linejoin="miter"></rect> <rect data-color="color-2" x="5" y="5" fill="none" stroke="#4a5261" stroke-width="2" stroke-linecap="square" stroke-miterlimit="10" width="5" height="5" stroke-linejoin="miter"></rect> <rect data-color="color-2" x="14" y="5" fill="none" stroke="#4a5261" stroke-width="2" stroke-linecap="square" stroke-miterlimit="10" width="5" height="5" stroke-linejoin="miter"></rect> <rect data-color="color-2" x="5" y="14" fill="none" stroke="#4a5261" stroke-width="2" stroke-linecap="square" stroke-miterlimit="10" width="5" height="5" stroke-linejoin="miter"></rect> <rect data-color="color-2" x="14" y="14" fill="none" stroke="#4a5261" stroke-width="2" stroke-linecap="square" stroke-miterlimit="10" width="5" height="5" stroke-linejoin="miter"></rect> </g></svg>
Projects
</a>
</li>
<li>
<a href="#0" data-menu="contact">
<svg class="nc-icon outline" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="24px" height="24px" viewBox="0 0 24 24"><g transform="translate(0, 0)"> <polyline data-color="color-2" fill="none" stroke="#4a5261" stroke-width="2" stroke-linecap="square" stroke-miterlimit="10" points=" 19,7 12,14 5,7 " stroke-linejoin="miter"></polyline> <rect x="1" y="3" fill="none" stroke="#4a5261" stroke-width="2" stroke-linecap="square" stroke-miterlimit="10" width="22" height="18" stroke-linejoin="miter"></rect> <line data-color="color-2" fill="none" stroke="#4a5261" stroke-width="2" stroke-linecap="square" stroke-miterlimit="10" x1="7" y1="15" x2="5" y2="17" stroke-linejoin="miter"></line> <line data-color="color-2" fill="none" stroke="#4a5261" stroke-width="2" stroke-linecap="square" stroke-miterlimit="10" x1="17" y1="15" x2="19" y2="17" stroke-linejoin="miter"></line> </g></svg>
</svg>
Contact
</a>
</li>
</ul>
</nav> <!-- .cd-side-navigation -->
<main class="cd-main">
<section class="cd-section index visible">
<header>
<a href="#index-content" class="cd-scroll">Scroll Down</a>
</header>
<div class="cd-content" id="index-content">
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quae illo veritatis ea deserunt aliquam blanditiis, voluptas optio, voluptate ut accusamus veniam numquam, porro! Cum minima a molestiae, similique voluptate, perferendis vel iusto quam suscipit delectus dolore ducimus possimus illo molestias voluptas labore optio consequuntur sapiente pariatur libero nam temporibus. Laudantium!
</p>
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quae illo veritatis ea deserunt aliquam blanditiis, voluptas optio, voluptate ut accusamus veniam numquam, porro! Cum minima a molestiae, similique voluptate, perferendis vel iusto quam suscipit delectus dolore ducimus possimus illo molestias voluptas labore optio consequuntur sapiente pariatur libero nam temporibus. Laudantium!
</p>
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quae illo veritatis ea deserunt aliquam blanditiis, voluptas optio, voluptate ut accusamus veniam numquam, porro! Cum minima a molestiae, similique voluptate, perferendis vel iusto quam suscipit delectus dolore ducimus possimus illo molestias voluptas labore optio consequuntur sapiente pariatur libero nam temporibus. Laudantium!
</p>
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quae illo veritatis ea deserunt aliquam blanditiis, voluptas optio, voluptate ut accusamus veniam numquam, porro! Cum minima a molestiae, similique voluptate, perferendis vel iusto quam suscipit delectus dolore ducimus possimus illo molestias voluptas labore optio consequuntur sapiente pariatur libero nam temporibus. Laudantium!
</p>
</div> <!-- .cd-content -->
</section> <!-- .cd-section -->
</main> <!-- .cd-main -->
<div id="cd-loading-bar" data-scale="1" class="index"></div> <!-- lateral loading bar -->
<script src="js/jquery-2.1.4.js"></script>
<script src="js/velocity.min.js"></script>
<script src="js/main.js"></script> <!-- Resource jQuery -->
</body>
</html>
JS代码(main.js):
jQuery(document).ready(function($){
//set some variablesvar isAnimating = false,firstLoad = false,newScaleValue = 1;
//cache DOM elementsvar dashboard = $('.cd-side-navigation'),mainContent = $('.cd-main'),loadingBar = $('#cd-loading-bar');
//select a new sectiondashboard.on('click','a',function(event){
event.preventDefault();
var target = $(this),//detect which section user has chosensectionTarget = target.data('menu');
if( !target.hasClass('selected') && !isAnimating ){
//if user has selected a section different from the one alredy visible - load the new contenttriggerAnimation(sectionTarget,true);
}
firstLoad = true;
}
);
//detect the 'popstate' event - e.g. user clicking the back button$(window).on('popstate',function(){
if( firstLoad ){
/* Safari emits a popstate event on page load - check if firstLoad is true before animating if it's false - the page has just been loaded */
var newPageArray = location.pathname.split('/'),//this is the url of the page to be loaded newPage = newPageArray[newPageArray.length - 1].replace('.html','');
if( !isAnimating ) triggerAnimation(newPage,false);
}
firstLoad = true;
}
);
//scroll to content if user clicks the .cd-scroll iconmainContent.on('click','.cd-scroll',function(event){
event.preventDefault();
var scrollId = $(this.hash);
$(scrollId).velocity('scroll',{
container:$(".cd-section")}
,200);
}
);
//start animationfunction triggerAnimation(newSection,bool){
isAnimating = true;
newSection = ( newSection == '' ) ? 'index':newSection;
//update dashboarddashboard.find('*[data-menu="'+newSection+'"]').addClass('selected').parent('li').siblings('li').children('.selected').removeClass('selected');
//trigger loading bar animationinitializeLoadingBar(newSection);
//load new contentloadNewContent(newSection,bool);
}
function initializeLoadingBar(section){
varselectedItem = dashboard.find('.selected'),barHeight = selectedItem.outerHeight(),barTop = selectedItem.offset().top,windowHeight = $(window).height(),maxOffset = ( barTop + barHeight/2 > windowHeight/2 ) ? barTop:windowHeight- barTop - barHeight,scaleValue = ((2*maxOffset+barHeight)/barHeight).toFixed(3)/1 + 0.001;
//place the loading bar next to the selected dashboard elementloadingBar.data('scale',scaleValue).css({
height:barHeight,top:barTop}
).attr('class','').addClass('loading '+section);
}
function loadNewContent(newSection,bool){
setTimeout(function(){
//animate loading barloadingBarAnimation();
//create a new section element and insert it into the DOMvar section = $('<section class="cd-section overflow-hidden '+newSection+'"></section>').appendTo(mainContent);
//load the new content from the proper html filesection.load(newSection+'.html .cd-section > *',function(event){
//finish up the animation and then make the new section visiblevar scaleMax = loadingBar.data('scale');
loadingBar.velocity('stop').velocity({
scaleY:scaleMax}
,400,function(){
//add the .visible class to the new section element -> it will cover the old onesection.prev('.visible').removeClass('visible').end().addClass('visible').on('webkitTransitionEnd otransitionend oTransitionEnd msTransitionEnd transitionend',function(){
resetAfterAnimation(section);
}
);
//if browser doesn't support transitionif( $('.no-csstransitions').length > 0 ){
resetAfterAnimation(section);
}
var url = newSection+'.html';
if(url!=window.location && bool){
//add the new page to the window.history //if the new page was triggered by a 'popstate' event,don't add it window.history.pushState({
path:url}
,'',url);
}
}
);
}
);
}
,50);
}
function loadingBarAnimation(){
var scaleMax = loadingBar.data('scale');
if( newScaleValue + 1 < scaleMax){
newScaleValue = newScaleValue + 1;
}
else if ( newScaleValue + 0.5 < scaleMax ){
newScaleValue = newScaleValue + 0.5;
}
loadingBar.velocity({
scaleY:newScaleValue}
,100,loadingBarAnimation);
}
function resetAfterAnimation(newSection){
//once the new section animation is over,remove the old section and make the new one scrollablenewSection.removeClass('overflow-hidden').prev('.cd-section').remove();
isAnimating = false;
//reset your loading barresetLoadingBar();
}
function resetLoadingBar(){
loadingBar.removeClass('loading').velocity({
scaleY:1}
,1);
}
}
);
JS代码(modernizr.js):
/* Modernizr 2.8.3 (Custom Build) | MIT & BSD * Build:http://modernizr.com/download/#-fontface-backgroundsize-borderimage-borderradius-boxshadow-flexbox-hsla-multiplebgs-opacity-rgba-textshadow-cssanimations-csscolumns-generatedcontent-cssgradients-cssreflections-csstransforms-csstransforms3d-csstransitions-applicationcache-canvas-canvastext-draganddrop-hashchange-history-audio-video-indexeddb-input-inputtypes-localstorage-postmessage-sessionstorage-websockets-websqldatabase-webworkers-geolocation-inlinesvg-smil-svg-svgclippaths-touch-webgl-shiv-cssclasses-addtest-prefixed-teststyles-testprop-testallprops-hasevent-prefixes-domprefixes-load */
;
window.Modernizr=function(a,b,c){
function C(a){
j.cssText=a}
function D(a,b){
return C(n.join(a+";
")+(b||""))}
function E(a,b){
return typeof a===b}
function F(a,b){
return!!~(""+a).indexOf(b)}
function G(a,b){
for(var d in a){
var e=a[d];
if(!F(e,"-")&&j[e]!==c)return b=="pfx"?e:!0}
return!1}
function H(a,b,d){
for(var e in a){
var f=b[a[e]];
if(f!==c)return d===!1?a[e]:E(f,"function")?f.bind(d||b):f}
return!1}
function I(a,b,c){
var d=a.charAt(0).toUpperCase()+a.slice(1),e=(a+" "+p.join(d+" ")+d).split(" ");
return E(b,"string")||E(b,"undefined")?G(e,b):(e=(a+" "+q.join(d+" ")+d).split(" "),H(e,b,c))}
function J(){
e.input=function(c){
for(var d=0,e=c.length;
d<e;
d++)u[c[d]]=c[d]in k;
return u.list&&(u.list=!!b.createElement("datalist")&&!!a.HTMLDataListElement),u}
("autocomplete autofocus list placeholder max min multiple pattern required step".split(" ")),e.inputtypes=function(a){
for(var d=0,e,f,h,i=a.length;
d<i;
d++)k.setAttribute("type",f=a[d]),e=k.type!=="text",e&&(k.value=l,k.style.cssText="position:absolute;
visibility:hidden;
",/^range$/.test(f)&&k.style.WebkitAppearance!==c?(g.appendChild(k),h=b.defaultView,e=h.getComputedStyle&&h.getComputedStyle(k,null).WebkitAppearance!=="textfield"&&k.offsetHeight!==0,g.removeChild(k)):/^(search|tel)$/.test(f)||(/^(url|email)$/.test(f)?e=k.checkValidity&&k.checkValidity()===!1:e=k.value!=l)),t[a[d]]=!!e;
return t}
("search tel url email datetime date month week time datetime-local number range color".split(" "))}
var d="2.8.3",e={
}
,f=!0,g=b.documentElement,h="modernizr",i=b.createElement(h),j=i.style,k=b.createElement("input"),l=":)",m={
}
.toString,n=" -webkit- -moz- -o- -ms- ".split(" "),o="Webkit Moz O ms",p=o.split(" "),q=o.toLowerCase().split(" "),r={
svg:"http://www.w3.org/2000/svg"}
,s={
}
,t={
}
,u={
}
,v=[],w=v.slice,x,y=function(a,c,d,e){
var f,i,j,k,l=b.createElement("div"),m=b.body,n=m||b.createElement("body");
if(parseInt(d,10))while(d--)j=b.createElement("div"),j.id=e?e[d]:h+(d+1),l.appendChild(j);
return f=["­
",'<style id="s',h,'">',a,"</style>"].join(""),l.id=h,(m?l:n).innerHTML+=f,n.appendChild(l),m||(n.style.background="",n.style.overflow="hidden",k=g.style.overflow,g.style.overflow="hidden",g.appendChild(n)),i=c(l,a),m?l.parentNode.removeChild(l):(n.parentNode.removeChild(n),g.style.overflow=k),!!i}
,z=function(){
function d(d,e){
e=e||b.createElement(a[d]||"div"),d="on"+d;
var f=d in e;
return f||(e.setAttribute||(e=b.createElement("div")),e.setAttribute&&e.removeAttribute&&(e.setAttribute(d,""),f=E(e[d],"function"),E(e[d],"undefined")||(e[d]=c),e.removeAttribute(d))),e=null,f}
var a={
select:"input",change:"input",submit:"form",reset:"form",error:"img",load:"img",abort:"img"}
;
return d}
(),A={
}
.hasOwnProperty,B;
!E(A,"undefined")&&!E(A.call,"undefined")?B=function(a,b){
return A.call(a,b)}
:B=function(a,b){
return b in a&&E(a.constructor.prototype[b],"undefined")}
,Function.prototype.bind||(Function.prototype.bind=function(b){
var c=this;
if(typeof c!="function")throw new TypeError;
var d=w.call(arguments,1),e=function(){
if(this instanceof e){
var a=function(){
}
;
a.prototype=c.prototype;
var f=new a,g=c.apply(f,d.concat(w.call(arguments)));
return Object(g)===g?g:f}
return c.apply(b,d.concat(w.call(arguments)))}
;
return e}
),s.flexbox=function(){
return I("flexWrap")}
,s.canvas=function(){
var a=b.createElement("canvas");
return!!a.getContext&&!!a.getContext("2d")}
,s.canvastext=function(){
return!!e.canvas&&!!E(b.createElement("canvas").getContext("2d").fillText,"function")}
,s.webgl=function(){
return!!a.WebGLRenderingContext}
,s.touch=function(){
var c;
return"ontouchstart"in a||a.DocumentTouch&&b instanceof DocumentTouch?c=!0:y(["@media (",n.join("touch-enabled),("),h,")","{
#modernizr{
top:9px;
position:absolute}
}
"].join(""),function(a){
c=a.offsetTop===9}
),c}
,s.geolocation=function(){
return"geolocation"in navigator}
,s.postmessage=function(){
return!!a.postMessage}
,s.websqldatabase=function(){
return!!a.openDatabase}
,s.indexedDB=function(){
return!!I("indexedDB",a)}
,s.hashchange=function(){
return z("hashchange",a)&&(b.documentMode===c||b.documentMode>7)}
,s.history=function(){
return!!a.history&&!!history.pushState}
,s.draganddrop=function(){
var a=b.createElement("div");
return"draggable"in a||"ondragstart"in a&&"ondrop"in a}
,s.websockets=function(){
return"WebSocket"in a||"MozWebSocket"in a}
,s.rgba=function(){
return C("background-color:rgba(150,255,150,.5)"),F(j.backgroundColor,"rgba")}
,s.hsla=function(){
return C("background-color:hsla(120,40%,100%,.5)"),F(j.backgroundColor,"rgba")||F(j.backgroundColor,"hsla")}
,s.multiplebgs=function(){
return C("background:url(https://),url(https://),red url(https://)"),/(url\s*\(.*?){
3}
/.test(j.background)}
,s.backgroundsize=function(){
return I("backgroundSize")}
,s.borderimage=function(){
return I("borderImage")}
,s.borderradius=function(){
return I("borderRadius")}
,s.boxshadow=function(){
return I("boxShadow")}
,s.textshadow=function(){
return b.createElement("div").style.textShadow===""}
,s.opacity=function(){
return D("opacity:.55"),/^0.55$/.test(j.opacity)}
,s.cssanimations=function(){
return I("animationName")}
,s.csscolumns=function(){
return I("columnCount")}
,s.cssgradients=function(){
var a="background-image:",b="gradient(linear,left top,right bottom,from(#9f9),to(white));
",c="linear-gradient(left top,#9f9,white);
";
return C((a+"-webkit- ".split(" ").join(b+a)+n.join(c+a)).slice(0,-a.length)),F(j.backgroundImage,"gradient")}
,s.cssreflections=function(){
return I("boxReflect")}
,s.csstransforms=function(){
return!!I("transform")}
,s.csstransforms3d=function(){
var a=!!I("perspective");
return a&&"webkitPerspective"in g.style&&y("@media (transform-3d),(-webkit-transform-3d){
#modernizr{
left:9px;
position:absolute;
height:3px;
}
}
",function(b,c){
a=b.offsetLeft===9&&b.offsetHeight===3}
),a}
,s.csstransitions=function(){
return I("transition")}
,s.fontface=function(){
var a;
return y('@font-face{
font-family:"font";
src:url("https://")}
',function(c,d){
var e=b.getElementById("smodernizr"),f=e.sheet||e.styleSheet,g=f?f.cssRules&&f.cssRules[0]?f.cssRules[0].cssText:f.cssText||"":"";
a=/src/i.test(g)&&g.indexOf(d.split(" ")[0])===0}
),a}
,s.generatedcontent=function(){
var a;
return y(["#",h,"{
font:0/0 a}
#",h,':after{
content:"',l,'";
visibility:hidden;
font:3px/1 a}
'].join(""),function(b){
a=b.offsetHeight>=3}
),a}
,s.video=function(){
var a=b.createElement("video"),c=!1;
try{
if(c=!!a.canPlayType)c=new Boolean(c),c.ogg=a.canPlayType('video/ogg;
codecs="theora"').replace(/^no$/,""),c.h264=a.canPlayType('video/mp4;
codecs="avc1.42E01E"').replace(/^no$/,""),c.webm=a.canPlayType('video/webm;
codecs="vp8,vorbis"').replace(/^no$/,"")}
catch(d){
}
return c}
,s.audio=function(){
var a=b.createElement("audio"),c=!1;
try{
if(c=!!a.canPlayType)c=new Boolean(c),c.ogg=a.canPlayType('audio/ogg;
codecs="vorbis"').replace(/^no$/,""),c.mp3=a.canPlayType("audio/mpeg;
").replace(/^no$/,""),c.wav=a.canPlayType('audio/wav;
codecs="1"').replace(/^no$/,""),c.m4a=(a.canPlayType("audio/x-m4a;
")||a.canPlayType("audio/aac;
")).replace(/^no$/,"")}
catch(d){
}
return c}
,s.localstorage=function(){
try{
return localStorage.setItem(h,h),localStorage.removeItem(h),!0}
catch(a){
return!1}
}
,s.sessionstorage=function(){
try{
return sessionStorage.setItem(h,h),sessionStorage.removeItem(h),!0}
catch(a){
return!1}
}
,s.webworkers=function(){
return!!a.Worker}
,s.applicationcache=function(){
return!!a.applicationCache}
,s.svg=function(){
return!!b.createElementNS&&!!b.createElementNS(r.svg,"svg").createSVGRect}
,s.inlinesvg=function(){
var a=b.createElement("div");
return a.innerHTML="<svg/>",(a.firstChild&&a.firstChild.namespaceURI)==r.svg}
,s.smil=function(){
return!!b.createElementNS&&/SVGAnimate/.test(m.call(b.createElementNS(r.svg,"animate")))}
,s.svgclippaths=function(){
return!!b.createElementNS&&/SVGClipPath/.test(m.call(b.createElementNS(r.svg,"clipPath")))}
;
for(var K in s)B(s,K)&&(x=K.toLowerCase(),e[x]=s[K](),v.push((e[x]?"":"no-")+x));
return e.input||J(),e.addTest=function(a,b){
if(typeof a=="object")for(var d in a)B(a,d)&&e.addTest(d,a[d]);
else{
a=a.toLowerCase();
if(e[a]!==c)return e;
b=typeof b=="function"?b():b,typeof f!="undefined"&&f&&(g.className+=" "+(b?"":"no-")+a),e[a]=b}
return e}
,C(""),i=k=null,function(a,b){
function l(a,b){
var c=a.createElement("p"),d=a.getElementsByTagName("head")[0]||a.documentElement;
return c.innerHTML="x<style>"+b+"</style>",d.insertBefore(c.lastChild,d.firstChild)}
function m(){
var a=s.elements;
return typeof a=="string"?a.split(" "):a}
function n(a){
var b=j[a[h]];
return b||(b={
}
,i++,a[h]=i,j[i]=b),b}
function o(a,c,d){
c||(c=b);
if(k)return c.createElement(a);
d||(d=n(c));
var g;
return d.cache[a]?g=d.cache[a].cloneNode():f.test(a)?g=(d.cache[a]=d.createElem(a)).cloneNode():g=d.createElem(a),g.canHaveChildren&&!e.test(a)&&!g.tagUrn?d.frag.appendChild(g):g}
function p(a,c){
a||(a=b);
if(k)return a.createDocumentFragment();
c=c||n(a);
var d=c.frag.cloneNode(),e=0,f=m(),g=f.length;
for(;
e<g;
e++)d.createElement(f[e]);
return d}
function q(a,b){
b.cache||(b.cache={
}
,b.createElem=a.createElement,b.createFrag=a.createDocumentFragment,b.frag=b.createFrag()),a.createElement=function(c){
return s.shivMethods?o(c,a,b):b.createElem(c)}
,a.createDocumentFragment=Function("h,f","return function(){
var n=f.cloneNode(),c=n.createElement;
h.shivMethods&&("+m().join().replace(/[\w\-]+/g,function(a){
return b.createElem(a),b.frag.createElement(a),'c("'+a+'")'}
)+");
return n}
")(s,b.frag)}
function r(a){
a||(a=b);
var c=n(a);
return s.shivCSS&&!g&&!c.hasCSS&&(c.hasCSS=!!l(a,"article,aside,dialog,figcaption,figure,footer,header,hgroup,main,nav,section{
display:block}
mark{
background:#FF0;
color:#000}
template{
display:none}
")),k||q(a,c),a}
var c="3.7.0",d=a.html5||{
}
,e=/^<|^(?:button|map|select|textarea|object|iframe|option|optgroup)$/i,f=/^(?:a|b|code|div|fieldset|h1|h2|h3|h4|h5|h6|i|label|li|ol|p|q|span|strong|style|table|tbody|td|th|tr|ul)$/i,g,h="_html5shiv",i=0,j={
}
,k;
(function(){
try{
var a=b.createElement("a");
a.innerHTML="<xyz></xyz>",g="hidden"in a,k=a.childNodes.length==1||function(){
b.createElement("a");
var a=b.createDocumentFragment();
return typeof a.cloneNode=="undefined"||typeof a.createDocumentFragment=="undefined"||typeof a.createElement=="undefined"}
()}
catch(c){
g=!0,k=!0}
}
)();
var s={
elements:d.elements||"abbr article aside audio bdi canvas data datalist details dialog figcaption figure footer header hgroup main mark meter nav output progress section summary template time video",version:c,shivCSS:d.shivCSS!==!1,supportsUnknownElements:k,shivMethods:d.shivMethods!==!1,type:"default",shivDocument:r,createElement:o,createDocumentFragment:p}
;
a.html5=s,r(b)}
(this,b),e._version=d,e._prefixes=n,e._domPrefixes=q,e._cssomPrefixes=p,e.hasEvent=z,e.testProp=function(a){
return G([a])}
,e.testAllProps=I,e.testStyles=y,e.prefixed=function(a,b,c){
return b?I(a,b,c):I(a,"pfx")}
,g.className=g.className.replace(/(^|\s)no-js(\s|$)/,"$1$2")+(f?" js "+v.join(" "):""),e}
(this,this.document),function(a,b,c){
function d(a){
return"[object Function]"==o.call(a)}
function e(a){
return"string"==typeof a}
function f(){
}
function g(a){
return!a||"loaded"==a||"complete"==a||"uninitialized"==a}
function h(){
var a=p.shift();
q=1,a?a.t?m(function(){
("c"==a.t?B.injectCss:B.injectJs)(a.s,0,a.a,a.x,a.e,1)}
,0):(a(),h()):q=0}
function i(a,c,d,e,f,i,j){
function k(b){
if(!o&&g(l.readyState)&&(u.r=o=1,!q&&h(),l.onload=l.onreadystatechange=null,b)){
"img"!=a&&m(function(){
t.removeChild(l)}
,50);
for(var d in y[c])y[c].hasOwnProperty(d)&&y[c][d].onload()}
}
var j=j||B.errorTimeout,l=b.createElement(a),o=0,r=0,u={
t:d,s:c,e:f,a:i,x:j}
;
1===y[c]&&(r=1,y[c]=[]),"object"==a?l.data=c:(l.src=c,l.type=a),l.width=l.height="0",l.onerror=l.onload=l.onreadystatechange=function(){
k.call(this,r)}
,p.splice(e,0,u),"img"!=a&&(r||2===y[c]?(t.insertBefore(l,s?null:n),m(k,j)):y[c].push(l))}
function j(a,b,c,d,f){
return q=0,b=b||"j",e(a)?i("c"==b?v:u,a,b,this.i++,c,d,f):(p.splice(this.i++,0,a),1==p.length&&h()),this}
function k(){
var a=B;
return a.loader={
load:j,i:0}
,a}
var l=b.documentElement,m=a.setTimeout,n=b.getElementsByTagName("script")[0],o={
}
.toString,p=[],q=0,r="MozAppearance"in l.style,s=r&&!!b.createRange().compareNode,t=s?l:n.parentNode,l=a.opera&&"[object Opera]"==o.call(a.opera),l=!!b.attachEvent&&!l,u=r?"object":l?"script":"img",v=l?"script":u,w=Array.isArray||function(a){
return"[object Array]"==o.call(a)}
,x=[],y={
}
,z={
timeout:function(a,b){
return b.length&&(a.timeout=b[0]),a}
}
,A,B;
B=function(a){
function b(a){
var a=a.split("!"),b=x.length,c=a.pop(),d=a.length,c={
url:c,origUrl:c,prefixes:a}
,e,f,g;
for(f=0;
f<d;
f++)g=a[f].split("="),(e=z[g.shift()])&&(c=e(c,g));
for(f=0;
f<b;
f++)c=x[f](c);
return c}
function g(a,e,f,g,h){
var i=b(a),j=i.autoCallback;
i.url.split(".").pop().split("?").shift(),i.bypass||(e&&(e=d(e)?e:e[a]||e[g]||e[a.split("/").pop().split("?")[0]]),i.instead?i.instead(a,e,f,g,h):(y[i.url]?i.noexec=!0:y[i.url]=1,f.load(i.url,i.forceCSS||!i.forceJS&&"css"==i.url.split(".").pop().split("?").shift()?"c":c,i.noexec,i.attrs,i.timeout),(d(e)||d(j))&&f.load(function(){
k(),e&&e(i.origUrl,h,g),j&&j(i.origUrl,h,g),y[i.url]=2}
)))}
function h(a,b){
function c(a,c){
if(a){
if(e(a))c||(j=function(){
var a=[].slice.call(arguments);
k.apply(this,a),l()}
),g(a,j,b,0,h);
else if(Object(a)===a)for(n in m=function(){
var b=0,c;
for(c in a)a.hasOwnProperty(c)&&b++;
return b}
(),a)a.hasOwnProperty(n)&&(!c&&!--m&&(d(j)?j=function(){
var a=[].slice.call(arguments);
k.apply(this,a),l()}
:j[n]=function(a){
return function(){
var b=[].slice.call(arguments);
a&&a.apply(this,b),l()}
}
(k[n])),g(a[n],j,b,n,h))}
else!c&&l()}
var h=!!a.test,i=a.load||a.both,j=a.callback||f,k=j,l=a.complete||f,m,n;
c(h?a.yep:a.nope,!!i),i&&c(i)}
var i,j,l=this.yepnope.loader;
if(e(a))g(a,0,l,0);
else if(w(a))for(i=0;
i<a.length;
i++)j=a[i],e(j)?g(j,0,l,0):w(j)?B(j):Object(j)===j&&h(j,l);
else Object(a)===a&&h(a,l)}
,B.addPrefix=function(a,b){
z[a]=b}
,B.addFilter=function(a){
x.push(a)}
,B.errorTimeout=1e4,null==b.readyState&&b.addEventListener&&(b.readyState="loading",b.addEventListener("DOMContentLoaded",A=function(){
b.removeEventListener("DOMContentLoaded",A,0),b.readyState="complete"}
,0)),a.yepnope=k(),a.yepnope.executeStack=h,a.yepnope.injectJs=function(a,c,d,e,i,j){
var k=b.createElement("script"),l,o,e=e||B.errorTimeout;
k.src=a;
for(o in d)k.setAttribute(o,d[o]);
c=j?h:c||f,k.onreadystatechange=k.onload=function(){
!l&&g(k.readyState)&&(l=1,c(),k.onload=k.onreadystatechange=null)}
,m(function(){
l||(l=1,c(1))}
,e),i?k.onload():n.parentNode.insertBefore(k,n)}
,a.yepnope.injectCss=function(a,c,d,e,g,i){
var e=b.createElement("link"),j,c=i?h:c||f;
e.href=a,e.rel="stylesheet",e.type="text/css";
for(j in d)e.setAttribute(j,d[j]);
g||(n.parentNode.insertBefore(e,n),m(c,0))}
}
(this,document),Modernizr.load=function(){
yepnope.apply(window,[].slice.call(arguments,0))}
;
CSS代码(style.css):
/* --------------------------------Primary style-------------------------------- */
*,*::after,*::before{box-sizing:border-box;}
html{font-size:62.5%;}
body{font-size:1.6rem;font-family:"PT Sans",sans-serif;color:#83b0b9;background-color:#343943;}
a{color:#d35657;text-decoration:none;}
/* --------------------------------Navigation-------------------------------- */
.cd-side-navigation{position:fixed;z-index:3;top:0;left:0;height:100vh;width:74px;overflow:hidden;}
.cd-side-navigation::before{/* background color of the side navigation */
content:'';position:absolute;top:0;left:0;height:100%;width:-webkit-calc(100% - 4px);width:calc(100% - 4px);background-color:#131519;}
.cd-side-navigation ul{height:100%;overflow-y:auto;-webkit-overflow-scrolling:touch;}
.cd-side-navigation li{width:-webkit-calc(100% - 4px);width:calc(100% - 4px);}
.cd-side-navigation a{display:block;position:relative;padding:4em 0 1.5em;font-size:1.2rem;text-align:center;color:#4a5261;-webkit-transition:background-color 0.2s,color 0.2s;-moz-transition:background-color 0.2s,color 0.2s;transition:background-color 0.2s,color 0.2s;}
.cd-side-navigation a svg{/* this is the icon */
position:absolute;left:50%;right:auto;-webkit-transform:translateX(-50%);-moz-transform:translateX(-50%);-ms-transform:translateX(-50%);-o-transform:translateX(-50%);transform:translateX(-50%);top:1.3em;}
.cd-side-navigation a svg *{-webkit-transition:stroke 0.2s;-moz-transition:stroke 0.2s;transition:stroke 0.2s;}
.cd-side-navigation a::after{/* 4px line to the right of the item - visible on hover */
content:'';position:absolute;top:0;right:-4px;height:100%;width:4px;background-color:#83b0b9;opacity:0;-webkit-transition:opacity 0.2s;-moz-transition:opacity 0.2s;transition:opacity 0.2s;pointer-events:none;}
.no-touch .cd-side-navigation a:hover{background-color:#08090b;}
.no-touch .cd-side-navigation a:hover::after{opacity:1;}
.cd-side-navigation a.selected,.no-touch .cd-side-navigation a.selected:hover{background-color:#ffffff;color:#131519;}
.cd-side-navigation a.selected > svg *,.no-touch .cd-side-navigation a.selected:hover > svg *{stroke:#83b0b9;}
.cd-side-navigation li:nth-of-type(2) .selected > svg *,.cd-side-navigation li:nth-of-type(2) .selected:hover > svg *{stroke:#d35657;}
.cd-side-navigation li:nth-of-type(3) .selected > svg *,.cd-side-navigation li:nth-of-type(3) .selected:hover > svg *{stroke:#343943;}
.cd-side-navigation li:nth-of-type(4) .selected > svg *,.cd-side-navigation li:nth-of-type(4) .selected:hover > svg *{stroke:#e4b162;}
.cd-side-navigation li:nth-of-type(2) a::after{background-color:#d35657;}
.cd-side-navigation li:nth-of-type(3) a::after{background-color:#343943;}
.cd-side-navigation li:nth-of-type(4) a::after{background-color:#e4b162;}
@media only screen and (min-width:480px){.cd-side-navigation{width:94px;}
.cd-side-navigation a{padding:4em 0 1.5em;font-size:1.3rem;}
.cd-side-navigation a svg{top:1.6em;}
}
/* -------------------------------- Main Content-------------------------------- */
.cd-main{height:100vh;overflow:hidden;}
.cd-section{position:absolute;z-index:1;top:0;left:0;height:100%;width:100%;overflow-y:auto;padding-left:70px;/* Force Hardware Acceleration */
-webkit-backface-visibility:hidden;backface-visibility:hidden;-webkit-transform:translateZ(0);-moz-transform:translateZ(0);-ms-transform:translateZ(0);-o-transform:translateZ(0);transform:translateZ(0);-webkit-transform:translateX(-100%);-moz-transform:translateX(-100%);-ms-transform:translateX(-100%);-o-transform:translateX(-100%);transform:translateX(-100%);-webkit-transition:-webkit-transform 0s 0.5s;-moz-transition:-moz-transform 0s 0.5s;transition:transform 0s 0.5s;}
.cd-section.overflow-hidden{/* this class is used to hide the scrolling bar while a new section is entering the viewport */
overflow:hidden;}
.cd-section header{position:relative;height:100vh;width:100%;background:#83b0b9;overflow:hidden;}
.cd-section.services header{background-color:#d35657;}
.cd-section.projects header{background-color:#343943;}
.cd-section.contact header{background-color:#e4b162;}
.cd-section .cd-scroll{/* this is the arrow at the bottom of the header */
display:block;position:absolute;bottom:60px;left:-webkit-calc(50vw - (74px - 4px)/2);left:calc(50vw - (74px - 4px)/2);width:44px;height:44px;/* image replacement */
overflow:hidden;text-indent:100%;white-space:nowrap;visibility:hidden;-webkit-transition:-webkit-transform 0s 0.5s,visibility 0s 0.5s;-moz-transition:-moz-transform 0s 0.5s,visibility 0s 0.5s;transition:transform 0s 0.5s,visibility 0s 0.5s;-webkit-transform:translateX(-50%) scale(0);-moz-transform:translateX(-50%) scale(0);-ms-transform:translateX(-50%) scale(0);-o-transform:translateX(-50%) scale(0);transform:translateX(-50%) scale(0);background:url("../img/cd-icon-arrow.svg") no-repeat center center;}
.cd-section.visible{/* this is the visible/selected section */
position:relative;z-index:2;-webkit-overflow-scrolling:touch;-webkit-transform:translateX(0);-moz-transform:translateX(0);-ms-transform:translateX(0);-o-transform:translateX(0);transform:translateX(0);-webkit-transition:-webkit-transform 0.5s 0s;-moz-transition:-moz-transform 0.5s 0s;transition:transform 0.5s 0s;}
.cd-section.visible .cd-scroll{visibility:visible;-webkit-transform:translateX(-50%) scale(1);-moz-transform:translateX(-50%) scale(1);-ms-transform:translateX(-50%) scale(1);-o-transform:translateX(-50%) scale(1);transform:translateX(-50%) scale(1);-webkit-transition:-webkit-transform 0.3s 0.5s,visibility 0s 0s;-moz-transition:-moz-transform 0.3s 0.5s,visibility 0s 0s;transition:transform 0.3s 0.5s,visibility 0s 0s;-webkit-animation:cd-scroll-down 1.2s 0.9s;-moz-animation:cd-scroll-down 1.2s 0.9s;animation:cd-scroll-down 1.2s 0.9s;-webkit-animation-iteration-count:2;-moz-animation-iteration-count:2;animation-iteration-count:2;}
@media only screen and (min-width:480px){.cd-section{padding-left:90px;}
.cd-section .cd-scroll{left:-webkit-calc(50vw - (94px - 4px)/2);left:calc(50vw - (94px - 4px)/2);}
}
@-webkit-keyframes cd-scroll-down{0%{-webkit-transform:translateX(-50%) scale(1);}
50%{-webkit-transform:translateY(10px) translateX(-50%) scale(1);}
100%{-webkit-transform:translateX(-50%) scale(1);}
}
@-moz-keyframes cd-scroll-down{0%{-moz-transform:translateX(-50%) scale(1);}
50%{-moz-transform:translateY(10px) translateX(-50%) scale(1);}
100%{-moz-transform:translateX(-50%) scale(1);}
}
@keyframes cd-scroll-down{0%{-webkit-transform:translateX(-50%) scale(1);-moz-transform:translateX(-50%) scale(1);-ms-transform:translateX(-50%) scale(1);-o-transform:translateX(-50%) scale(1);transform:translateX(-50%) scale(1);}
50%{-webkit-transform:translateY(10px) translateX(-50%) scale(1);-moz-transform:translateY(10px) translateX(-50%) scale(1);-ms-transform:translateY(10px) translateX(-50%) scale(1);-o-transform:translateY(10px) translateX(-50%) scale(1);transform:translateY(10px) translateX(-50%) scale(1);}
100%{-webkit-transform:translateX(-50%) scale(1);-moz-transform:translateX(-50%) scale(1);-ms-transform:translateX(-50%) scale(1);-o-transform:translateX(-50%) scale(1);transform:translateX(-50%) scale(1);}
}
.cd-title{position:absolute;top:50%;left:0;/* this prevents title from jumping when the section scroll bar is visible */
width:calc(100vw - 90px);padding:1em;color:#ffffff;text-align:center;/* Force Hardware Acceleration */
-webkit-backface-visibility:hidden;backface-visibility:hidden;-webkit-transform:translateZ(0);-moz-transform:translateZ(0);-ms-transform:translateZ(0);-o-transform:translateZ(0);transform:translateZ(0);opacity:0;-webkit-transform:translateY(-50%) translateX(-80px);-moz-transform:translateY(-50%) translateX(-80px);-ms-transform:translateY(-50%) translateX(-80px);-o-transform:translateY(-50%) translateX(-80px);transform:translateY(-50%) translateX(-80px);-webkit-transition:-webkit-transform 0s 0.5s,opacity 0s 0.5s;-moz-transition:-moz-transform 0s 0.5s,opacity 0s 0.5s;transition:transform 0s 0.5s,opacity 0s 0.5s;}
.cd-title h2{font-size:2.8rem;font-weight:700;margin-bottom:20px;}
.cd-title span{opacity:0.6;}
.visible .cd-title{opacity:1;-webkit-transform:translateY(-50%);-moz-transform:translateY(-50%);-ms-transform:translateY(-50%);-o-transform:translateY(-50%);transform:translateY(-50%);-webkit-transition:-webkit-transform 0.4s 0.3s,opacity 0.4s 0.3s;-moz-transition:-moz-transform 0.4s 0.3s,opacity 0.4s 0.3s;transition:transform 0.4s 0.3s,opacity 0.4s 0.3s;}
@media only screen and (min-width:768px){.cd-title h2{font-size:5rem;}
}
.cd-content{padding:2em 0;background-color:#ebebeb;}
.cd-content p{width:90%;max-width:800px;margin:0 auto 2em;font-size:1.4rem;line-height:1.6;color:#999999;}
@media only screen and (min-width:768px){.cd-content{padding:4em 0;}
.cd-content p{font-size:1.6rem;}
}
/* -------------------------------- Loading Bar-------------------------------- */
#cd-loading-bar{position:fixed;z-index:2;left:70px;width:4px;visibility:hidden;/* Force Hardware Acceleration */
-webkit-backface-visibility:hidden;backface-visibility:hidden;-webkit-transform:translateZ(0);-moz-transform:translateZ(0);-ms-transform:translateZ(0);-o-transform:translateZ(0);transform:translateZ(0);}
#cd-loading-bar.index{background-color:#83b0b9;}
#cd-loading-bar.services{background-color:#d35657;}
#cd-loading-bar.projects{background-color:#343943;}
#cd-loading-bar.contact{background-color:#e4b162;}
#cd-loading-bar.loading{visibility:visible;}
@media only screen and (min-width:480px){#cd-loading-bar{left:90px;}
}