html5顶部大图滑动展示图片网格布局代码



67 267 90



特效描述:html5顶部大图 滑动展示 图片网格布局,图片网格布局

代码结构

1. 引入CSS

<link rel="stylesheet" type="text/css" href="css/normalize.css" />
<link rel="stylesheet" type="text/css" href="css/demo.css" />
<link rel="stylesheet" type="text/css" href="css/layout-multi.css" />

2. 引入JS

<script src="js/modernizr.custom.js"></script>
<script src="js/classie.js"></script>

3. HTML代码

		<svg class="hidden">
			<g id="icon-grid">
				<rect x="32.5" y="5.5" width="22" height="22"/>
				<rect x="4.5" y="5.5" width="22" height="22"/>
				<rect x="32.5" y="33.5" width="22" height="22"/>
				<rect x="4.5" y="33.5" width="22" height="22"/>
			</g>
			<g id="icon-cross">
				<line x1="4.5" y1="55.5" x2="54.953" y2="5.046"/>
				<line x1="54.953" y1="55.5" x2="4.5" y2="5.047"/>
			</g>
		</svg>
		<nav class="thumb-nav">
			<a data-container="container-1" class="thumb-nav__item" href="#"><img src="img/thumbs/thumb1.png" alt="thumb01" /><span>1</span></a>
			<a data-container="container-2" class="thumb-nav__item" href="#"><img src="img/thumbs/thumb2.png" alt="thumb02" /><span>2</span></a>
			<a data-container="container-3" class="thumb-nav__item" href="#"><img src="img/thumbs/thumb3.png" alt="thumb03" /><span>3</span></a>
		</nav>
		<div id="container-1" class="container theme-1">
			<header class="intro">
				<img class="intro__image" src="img/header01.jpg" alt="Lava"/>
				<div class="intro__content">
					<h1 class="intro__title">Essential Feelings</h1>
					<div class="intro__subtitle">
						<div class="codrops-links">
							<a class="codrops-icon codrops-icon--prev" href="#" title="Previous Demo"><span>Previous Demo</span></a>
							<a class="codrops-icon codrops-icon--drop" href="#" title="Back to the a"><span>Back to the Codrops a</span></a>
						</div>
						<div class="intro__description">
							A multi-panel layout with intro headers and image grids. Photo courtesy of <a href="http://instagram.com/danrubin/">Dan Rubin</a>.
							<div class="demos">
								<a class="demos__item" href="index1.html">Simple</a>
								<a class="demos__item demos__item--current" href="index1.html">Multi</a>
							</div>
						</div>
						<button class="trigger">
							<svg width="100%" height="100%" viewBox="0 0 60 60" preserveAspectRatio="none">
								<use class="icon icon--grid" xlink:href="#icon-grid" />
								<use class="icon icon--cross" xlink:href="#icon-cross" />
							</svg>
							<span>Toggle content</span>
						</button>
					</div>
				</div><!-- /intro__content -->
			</header><!-- /intro -->
			<section class="items-wrap">
				<a href="#" class="item">
					<img class="item__image" src="img/item01.jpg" alt="item01"/>
					<h2 class="item__title">Magnificence</h2>
				</a>
				<a href="#" class="item">
					<img class="item__image" src="img/item02.jpg" alt="item02"/>
					<h2 class="item__title">Electrifying</h2>
				</a>
				<a href="#" class="item">
					<img class="item__image" src="img/item03.jpg" alt="item03"/>
					<h2 class="item__title">Dynamic</h2>
				</a>
				<a href="#" class="item">
					<img class="item__image" src="img/item04.jpg" alt="item04"/>
					<h2 class="item__title">Crucial</h2>
				</a>
				<a href="#" class="item">
					<img class="item__image" src="img/item05.jpg" alt="item05"/>
					<h2 class="item__title">Awe-inspiring</h2>
				</a>
				<a href="#" class="item">
					<img class="item__image" src="img/item06.jpg" alt="item06"/>
					<h2 class="item__title">Serene</h2>
				</a>
				<a href="#" class="item">
					<img class="item__image" src="img/item07.jpg" alt="item07"/>
					<h2 class="item__title">Vulnerable</h2>
				</a>
				<a href="#" class="item">
					<img class="item__image" src="img/item08.jpg" alt="item08"/>
					<h2 class="item__title">Bountiful</h2>
				</a>
				<a href="#" class="item">
					<img class="item__image" src="img/item09.jpg" alt="item09"/>
					<h2 class="item__title">Endangered</h2>
				</a>
				<a href="#" class="item">
					<img class="item__image" src="img/item10.jpg" alt="item10"/>
					<h2 class="item__title">Beautiful</h2>
				</a>
				<a href="#" class="item">
					<img class="item__image" src="img/item11.jpg" alt="item11"/>
					<h2 class="item__title">Inspiring</h2>
				</a>
				<a href="#" class="item">
					<img class="item__image" src="img/item12.jpg" alt="item12"/>
					<h2 class="item__title">Refreshing</h2>
				</a>
			</section>
		</div><!-- /container -->
		<div id="container-2" class="container theme-2">
			<header class="intro">
				<img class="intro__image" src="img/header02.jpg" alt="Road"/>
				<div class="intro__content">
					<h1 class="intro__title">Common Paths</h1>
					<div class="intro__subtitle">
						<div class="codrops-links">
							<a class="codrops-icon codrops-icon--prev" href="#" title="Previous Demo"><span>Previous Demo</span></a>
							<a class="codrops-icon codrops-icon--drop" href="#" title="Back to the a"><span>Back to the Codrops a</span></a>
						</div>
						<div class="intro__description">
							A multi-panel layout with intro headers and image grids. Photo courtesy of <a href="http://instagram.com/danrubin/">Dan Rubin</a>.
							<div class="demos">
								<span>More demos: </span>
								<a class="demos__item" href="index1.html">Simple</a>
								<a class="demos__item demos__item--current" href="index1.html">Multi</a>
							</div>
						</div>
						<button class="trigger">
							<svg width="100%" height="100%" viewBox="0 0 60 60" preserveAspectRatio="none">
								<use class="icon icon--grid" xlink:href="#icon-grid" />
								<use class="icon icon--cross" xlink:href="#icon-cross" />
							</svg>
							<span>Toggle content</span>
						</button>
					</div>
				</div><!-- /intro__content -->
			</header><!-- /intro -->
			<section class="items-wrap">
				<a href="#" class="item">
					<img class="item__image" src="img/item01.jpg" alt="item01"/>
					<h2 class="item__title">Magnificence</h2>
				</a>
				<a href="#" class="item">
					<img class="item__image" src="img/item02.jpg" alt="item02"/>
					<h2 class="item__title">Electrifying</h2>
				</a>
				<a href="#" class="item">
					<img class="item__image" src="img/item03.jpg" alt="item03"/>
					<h2 class="item__title">Dynamic</h2>
				</a>
				<a href="#" class="item">
					<img class="item__image" src="img/item04.jpg" alt="item04"/>
					<h2 class="item__title">Crucial</h2>
				</a>
				<a href="#" class="item">
					<img class="item__image" src="img/item05.jpg" alt="item05"/>
					<h2 class="item__title">Awe-inspiring</h2>
				</a>
				<a href="#" class="item">
					<img class="item__image" src="img/item06.jpg" alt="item06"/>
					<h2 class="item__title">Serene</h2>
				</a>
				<a href="#" class="item">
					<img class="item__image" src="img/item07.jpg" alt="item07"/>
					<h2 class="item__title">Vulnerable</h2>
				</a>
				<a href="#" class="item">
					<img class="item__image" src="img/item08.jpg" alt="item08"/>
					<h2 class="item__title">Bountiful</h2>
				</a>
				<a href="#" class="item">
					<img class="item__image" src="img/item09.jpg" alt="item09"/>
					<h2 class="item__title">Endangered</h2>
				</a>
				<a href="#" class="item">
					<img class="item__image" src="img/item10.jpg" alt="item10"/>
					<h2 class="item__title">Beautiful</h2>
				</a>
				<a href="#" class="item">
					<img class="item__image" src="img/item11.jpg" alt="item11"/>
					<h2 class="item__title">Inspiring</h2>
				</a>
				<a href="#" class="item">
					<img class="item__image" src="img/item12.jpg" alt="item12"/>
					<h2 class="item__title">Refreshing</h2>
				</a>
			</section>
		</div><!-- /container -->
		<div id="container-3" class="container">
			<header class="intro">
				<img class="intro__image" src="img/header03.jpg" alt="Glacier"/>
				<div class="intro__content">
					<h1 class="intro__title">On Serenity</h1>
					<div class="intro__subtitle">
						<div class="codrops-links">
							<a class="codrops-icon codrops-icon--prev" href="#" title="Previous Demo"><span>Previous Demo</span></a>
							<a class="codrops-icon codrops-icon--drop" href="#" title="Back to the a"><span>Back to the Codrops a</span></a>
						</div>
						<div class="intro__description">
							A multi-panel layout with intro headers and image grids. Photo courtesy of <a href="http://instagram.com/danrubin/">Dan Rubin</a>.
							<div class="demos">
								<span>More demos: </span>
								<a class="demos__item" href="index1.html">Simple</a>
								<a class="demos__item demos__item--current" href="index1.html">Multi</a>
							</div>
						</div>
						<button class="trigger">
							<svg width="100%" height="100%" viewBox="0 0 60 60" preserveAspectRatio="none">
								<use class="icon icon--grid" xlink:href="#icon-grid" />
								<use class="icon icon--cross" xlink:href="#icon-cross" />
							</svg>
							<span>Toggle content</span>
						</button>
					</div>
				</div><!-- /intro__content -->
			</header><!-- /intro -->
			<section class="items-wrap">
				<a href="#" class="item">
					<img class="item__image" src="img/item01.jpg" alt="item01"/>
					<h2 class="item__title">Magnificence</h2>
				</a>
				<a href="#" class="item">
					<img class="item__image" src="img/item02.jpg" alt="item02"/>
					<h2 class="item__title">Electrifying</h2>
				</a>
				<a href="#" class="item">
					<img class="item__image" src="img/item03.jpg" alt="item03"/>
					<h2 class="item__title">Dynamic</h2>
				</a>
				<a href="#" class="item">
					<img class="item__image" src="img/item04.jpg" alt="item04"/>
					<h2 class="item__title">Crucial</h2>
				</a>
				<a href="#" class="item">
					<img class="item__image" src="img/item05.jpg" alt="item05"/>
					<h2 class="item__title">Awe-inspiring</h2>
				</a>
				<a href="#" class="item">
					<img class="item__image" src="img/item06.jpg" alt="item06"/>
					<h2 class="item__title">Serene</h2>
				</a>
				<a href="#" class="item">
					<img class="item__image" src="img/item07.jpg" alt="item07"/>
					<h2 class="item__title">Vulnerable</h2>
				</a>
				<a href="#" class="item">
					<img class="item__image" src="img/item08.jpg" alt="item08"/>
					<h2 class="item__title">Bountiful</h2>
				</a>
				<a href="#" class="item">
					<img class="item__image" src="img/item09.jpg" alt="item09"/>
					<h2 class="item__title">Endangered</h2>
				</a>
				<a href="#" class="item">
					<img class="item__image" src="img/item10.jpg" alt="item10"/>
					<h2 class="item__title">Beautiful</h2>
				</a>
				<a href="#" class="item">
					<img class="item__image" src="img/item11.jpg" alt="item11"/>
					<h2 class="item__title">Inspiring</h2>
				</a>
				<a href="#" class="item">
					<img class="item__image" src="img/item12.jpg" alt="item12"/>
					<h2 class="item__title">Refreshing</h2>
				</a>
			</section>
		</div><!-- /container -->
		<script>
			(function() {
				var support = { animations : Modernizr.cssanimations },
					animEndEventNames = { 'WebkitAnimation' : 'webkitAnimationEnd', 'OAnimation' : 'oAnimationEnd', 'msAnimation' : 'MSAnimationEnd', 'animation' : 'animationend' },
					animEndEventName = animEndEventNames[ Modernizr.prefixed( 'animation' ) ],
					onEndAnimation = function( el, callback ) {
						var onEndCallbackFn = function( ev ) {
							if( support.animations ) {
								if( ev.target != this ) return;
								this.removeEventListener( animEndEventName, onEndCallbackFn );
							}
							if( callback && typeof callback === 'function' ) { callback.call(); }
						};
						if( support.animations ) {
							el.addEventListener( animEndEventName, onEndCallbackFn );
						}
						else {
							onEndCallbackFn();
						}
					};
				var containers = [].slice.call( document.querySelectorAll( '.container' ) ),
					containersCount = containers.length,
					nav = document.querySelector( 'nav.thumb-nav' ),
					pageTriggers = [].slice.call( nav.children ),
					isAnimating = false, current = 0;
				function init() {
					resetScroll();
					// disable scrolling
					window.addEventListener( 'scroll', noscroll );
					// set current page trigger
					classie.add( pageTriggers[ current ], 'thumb-nav__item--current' );
					// set current container
					classie.add( containers[ current ], 'container--current' );
					// initialize events
					initEvents();
				}
				function initEvents() {
					// slideshow navigation
					pageTriggers.forEach( function( pageTrigger ) {
						pageTrigger.addEventListener( 'click', function( ev ) {
							ev.preventDefault();
							navigate( this );
						} );
					} );
					// open each container's content area when clicking on the respective trigger button
					containers.forEach( function( container ) {
						container.querySelector( 'button.trigger' ).addEventListener( 'click', function() {
							toggleContent( container, this );
						} );
					} );
					// keyboard navigation events
					document.addEventListener( 'keydown', function( ev ) {
						var keyCode = ev.keyCode || ev.which,
							isContainerOpen = containers[ current ].getAttribute( 'data-open' ) == 'open';
						switch (keyCode) {
							// left key
							case 37:
								if( current > 0 && !isContainerOpen ) {
									navigate( pageTriggers[ current - 1 ] );
								}
								break;
							// right key
							case 39:
								if( current < containersCount - 1 && !isContainerOpen ) {
									navigate( pageTriggers[ current + 1 ] );
								}
								break;
						}
					} );
				}
				function navigate( pageTrigger ) {
					var oldcurrent = current,
						newcurrent = pageTriggers.indexOf( pageTrigger );
					if( isAnimating || oldcurrent === newcurrent ) return;
					isAnimating = true;
					// reset scroll
					allowScroll();
					resetScroll();
					preventScroll();
					var currentPageTrigger = pageTriggers[ current ],
						nextContainer = document.getElementById( pageTrigger.getAttribute( 'data-container' ) ),
						currentContainer = containers[ current ],
						dir = newcurrent > oldcurrent ? 'left' : 'right';
					classie.remove( currentPageTrigger, 'thumb-nav__item--current' );
					classie.add( pageTrigger, 'thumb-nav__item--current' );
					// update current
					current = newcurrent;
					// add animation classes
					classie.add( nextContainer, dir === 'left' ? 'container--animInRight' : 'container--animInLeft' );
					classie.add( currentContainer, dir === 'left' ? 'container--animOutLeft' : 'container--animOutRight' );
					onEndAnimation( currentContainer, function() {
						// clear animation classes
						classie.remove( currentContainer, dir === 'left' ? 'container--animOutLeft' : 'container--animOutRight' );
						classie.remove( nextContainer, dir === 'left' ? 'container--animInRight' : 'container--animInLeft' );
						// clear current class / set current class
						classie.remove( currentContainer, 'container--current' );
						classie.add( nextContainer, 'container--current' );
						isAnimating = false;
					} );
				}
				// show content section
				function toggleContent( container, trigger ) {
					if( classie.has( container, 'container--open' ) ) {
						classie.remove( container, 'container--open' );
						classie.remove( trigger, 'trigger--active' );
						classie.remove( nav, 'thumb-nav--hide' );
						container.setAttribute( 'data-open', '' );
						preventScroll();
					}
					else {
						classie.add( container, 'container--open' );
						classie.add( trigger, 'trigger--active' );
						classie.add( nav, 'thumb-nav--hide' );
						container.setAttribute( 'data-open', 'open' );
						allowScroll();
					}
				}
				// scroll functions
				function resetScroll() { document.body.scrollTop = document.documentElement.scrollTop = 0; }
				function preventScroll() { window.addEventListener( 'scroll', noscroll ); }
				function allowScroll() { window.removeEventListener( 'scroll', noscroll ); }
				function noscroll() { 
					window.scrollTo( 0, 0 ); 
				}
				init();
				// For Demo purposes only (prevent jump on click)
				[].slice.call( document.querySelectorAll('.items-wrap a') ).forEach( function(el) { el.onclick = function() { return false; } } );
			})();
		</script>



用户评论
大牛,别默默的看了,快登录帮我点评一下吧!:)      登录 | 注册


热门标签: 图片叠加 图片层叠 图片翻转 图片旋转 图片延迟加载 图片延迟 图片加载 图片拖动 图片拖拽 图片淡出淡进 图片淡出 图片淡进 图片全屏 头像上传 图片上传 二维码 图片放大镜 h5图片动画 h5图标动画 html5图片动画 html5图标动画 带缩略图的幻灯片 地图 中国地图 世界地图 滑动 滑块 滑动门 触屏滑动 滑动插件 滑块插件 图片放大缩小 图片缩放 图片大小 图片放大 图片缩小 图片变大 图片变小 滚动切换 滚动条切换 滑动选项卡 滑动切换 图片广告 图片收缩展开 图片收缩 图片展开 纯图片轮播 图片轮播 图片滚动 图片滚动条 图片滑动 图片滑块 旋转木马 图片旋转木马 文字旋转木马 旋转木马插件 图片切换 图片选项卡 图标选项卡 自动滚动图片轮播 图标导航 图标菜单 选项卡切换 选项卡 切换 tab切换 页面切换 选项卡插件 切换插件 滑动手风琴 背景切换 大图切换 手风琴 水平手风琴 垂直手风琴 图片手风琴 文字手风琴 手风琴插件 图表 图片 图片插件 头像截图 图片相册 相册图片 图片滑动 图片滑块 图片切换 图片选项卡 图标选项卡 图片网格 选项卡自动切换 图片滑动 滑动图片

×
×

注册

官方QQ群

扫描上面二维码加微信群

官方QQ群

jQuery/js讨论群
群号:642649996
Css3+Html5讨论群
群号:322131262

加群请备注:从官网了解到