Parallax.js云顶之上背景视差动画特效



192 767 256



特效描述:Parallax.js 云顶之上背景 视差动画特效,jquery.parallax.js制作云顶之上夜里灯塔背景跟随鼠标移动视差动画特效

代码结构

1. 引入CSS

<link rel="stylesheet" type="text/css" href="css/styles.css"/>

2. 引入JS

<script src="js/libraries.min.js"></script>
<script src="js/jquery.parallax.js"></script>

3. HTML代码

<div id="container" class="wrapper">
	<ul id="scene" class="scene unselectable" data-friction-x="0.1" data-friction-y="0.1" data-scalar-x="25" data-scalar-y="15">
		<li class="layer" data-depth="0.00"></li>
		<li class="layer" data-depth="0.10">
			<div class="background"></div>
		</li>
		<li class="layer" data-depth="0.10">
			<div class="light orange b phase-4"></div>
		</li>
		<li class="layer" data-depth="0.10">
			<div class="light purple c phase-5"></div>
		</li>
		<li class="layer" data-depth="0.10">
			<div class="light orange d phase-3"></div>
		</li>
		<li class="layer" data-depth="0.15">
			<ul class="rope depth-10">
				<li><img src="picture/rope.png" alt="Rope"></li>
				<li class="hanger position-2">
					<div class="board cloud-2 swing-1"></div>
				</li>
				<li class="hanger position-4">
					<div class="board cloud-1 swing-3"></div>
				</li>
				<li class="hanger position-8">
					<div class="board birds swing-5"></div>
				</li>
			</ul>
		</li>
		<li class="layer" data-depth="0.20"></li>
		<li class="layer" data-depth="0.30">
			<ul class="rope depth-30">
				<li><img src="picture/rope.png" alt="Rope"></li>
				<li class="hanger position-1">
					<div class="board cloud-1 swing-3"></div>
				</li>
				<li class="hanger position-5">
					<div class="board cloud-4 swing-1"></div>
				</li>
			</ul>
		</li>
		<li class="layer" data-depth="0.30">
			<div class="wave paint depth-30"></div>
		</li>
		<li class="layer" data-depth="0.40">
			<div class="wave plain depth-40"></div>
		</li>
		<li class="layer" data-depth="0.50">
			<div class="wave paint depth-50"></div>
		</li>
		<li class="layer" data-depth="0.60">
			<div class="lighthouse depth-60"></div>
		</li>
		<li class="layer" data-depth="0.60">
			<ul class="rope depth-60">
				<li><img src="picture/rope.png" alt="Rope"></li>
				<li class="hanger position-3">
					<div class="board birds swing-5"></div>
				</li>
				<li class="hanger position-6">
					<div class="board cloud-2 swing-2"></div>
				</li>
				<li class="hanger position-8">
					<div class="board cloud-3 swing-4"></div>
				</li>
			</ul>
		</li>
		<li class="layer" data-depth="0.60">
			<div class="wave plain depth-60"></div>
		</li>
		<li class="layer" data-depth="0.80">
			<div class="wave plain depth-80"></div>
		</li>
		<li class="layer" data-depth="1.00">
			<div class="wave paint depth-100"></div>
		</li>
	</ul>
	<section id="about" class="wrapper about hide accelerate">
		<div class="cell accelerate">
			<div class="cables center accelerate">
				<div class="panel accelerate">
					<header>
						<h1>parallax<em>.js</em></h1>
					</header>
					<p>WOW, that's deep man! <strong>parallax.js</strong> reacts to the orientation of your smart device, offsetting layers depending on their depth within a scene... Oh, you don't have a smart device? No worries, if no gyroscope or motion detection hardware is available, <strong>parallax.js</strong> uses the position of your cursor instead. Radical.</p>
					<br>
					<br>
				</div>
			</div>
		</div>
	</section>
	<button id="toggle" class="toggle i">
		<div class="cross">
			<div class="x"></div>
			<div class="y"></div>
		</div>
	</button>
	<div id="prompt" class="wrapper prompt hide accelerate">
		<div class="cell accelerate">
			<div class="panel center unselectable accelerate">
				<button id="dismiss" class="dismiss">
					<div class="cross">
						<div class="x"></div>
						<div class="y"></div>
					</div>
				</button>
				<div class="tilt-scene"> <img class="tilt" src="picture/tilt.png"> </div>
				<h2>Tilting is fun!</h2>
				<p>For the best experience, check out this site on a mobile or tablet equipped with a gyroscope</p>
				<p>(iPads are the coolest)</p>
			</div>
		</div>
	</div>
</div>
<script src="js/libraries.min.js"></script> 
<script src="js/jquery.parallax.js"></script> 
<script>
	// jQuery Selections
	var $html = $('html'),
		$container = $('#container'),
		$prompt = $('#prompt'),
		$toggle = $('#toggle'),
		$about = $('#about'),
		$scene = $('#scene');
	// Hide browser menu.
	(function() {
		setTimeout(function(){window.scrollTo(0,0);},0);
	})();
	// Setup FastClick.
	FastClick.attach(document.body);
	// Add touch functionality.
	if (Hammer.HAS_TOUCHEVENTS) {
		$container.hammer({drag_lock_to_axis: true});
		_.tap($html, 'a,button,[data-tap]');
	}
	// Add touch or mouse class to html element.
	$html.addClass(Hammer.HAS_TOUCHEVENTS ? 'touch' : 'mouse');
	// Resize handler.
	(resize = function() {
		$scene[0].style.width = window.innerWidth + 'px';
		$scene[0].style.height = window.innerHeight + 'px';
		if (!$prompt.hasClass('hide')) {
			if (window.innerWidth < 600) {
				$toggle.addClass('hide');
			} else {
				$toggle.removeClass('hide');
			}
		}
	})();
	// Attach window listeners.
	window.onresize = _.debounce(resize, 200);
	window.onscroll = _.debounce(resize, 200);
	function showDetails() {
		$about.removeClass('hide');
		$toggle.removeClass('i');
	}
	function hideDetails() {
		$about.addClass('hide');
		$toggle.addClass('i');
	}
	// Listen for toggle click event.
	$toggle.on('click', function(event) {
		$toggle.hasClass('i') ? showDetails() : hideDetails();
	});
	// Pretty simple huh?
	$scene.parallax();
	// Check for orientation support.
	setTimeout(function() {
		if ($scene.data('mode') === 'cursor') {
			$prompt.removeClass('hide');
			if (window.innerWidth < 600) $toggle.addClass('hide');
			$prompt.on('click', function(event) {
				$prompt.addClass('hide');
				if (window.innerWidth < 600) {
					setTimeout(function() {
						$toggle.removeClass('hide');
					},1200);
				}
			});
		}
	},1000);
</script>



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


热门标签: 瀑布流 收藏 预览 自适应页面大小 响应式区块列表布局 摇摆 烟花 清单样式 照相机 注释 下划线 结构图 鼠标悬停 条形码 弹幕 画板 朋友圈样式 红包 css绘制样式 支付 图文布局 顶部悬浮 底部悬浮 浮动导航菜单 右键菜单 html5动画导航菜单 二维码 图片广告 文字提示框 html5图片动画 地图 对联广告 提示框/弹出层 html5文字动画 计算器 layer 计时器 叠加浮动层 html5表情动画 lightbox 桌面 html5线条动画 跳转 Tooltip工具提示框 步骤 浮动提示框 html5飘落动画 键盘 html5弹窗动画 html5光标动画 签到 分享 html5悬停动画 点赞 投票 雪花 打印 答题 震动 图表 鼠标滑过 抽奖 表情 qq空间 头像截图 星星打分评分 编辑器 播放器 电子杂志 排行榜 分页翻页 排序 表格隔行变色 table表格 进度条 多功能 加载动画 悬浮浮动漂浮 弹出层拖动 窗口提示框 滑动星星打分 浮动提示框 html5弹窗动画 html5动画h5动画 其他更多 html5按钮动画

×
×

注册

官方QQ群

扫描上面二维码加微信群

官方QQ群

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

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