js背景悬浮飘动

index.html

<!DOCTYPE html>
<html>
<head>
	<!-- Article: http://www.paulrhayes.com/2009-04/auto-scrolling-parallax-effect-without-javascript/ -->
	<!-- Demo: http://www.paulrhayes.com/experiments/parallax/ -->
	<!-- Originally posted: 1st April 2009 -->
	<meta charset="UTF-8" />
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
	<title>Parallax effect built with CSS transitions — Paul Hayes</title>
	<meta name="author" content="Paul Hayes" />
	<link rel="stylesheet" href="../experiment-styles.css" />

	<link rel="stylesheet" href="css/experiment.css" />		
	<!--[if lt IE 9]><script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script><![endif]-->
</head>
<body class="experiment">
	<div id="wrapper">
		<p id="learn">
			This is a demo, <a href="http://www.paulrhayes.com/2009-04/auto-scrolling-parallax-effect-without-javascript/">learn how it works</a>.
		</p>
<div id="experiment">
	<div id="background"></div>	
	<div id="content">
		<h2>Mouse over to begin animation</h2>			
		<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>			
	</div>	
</div>
	</div>
	<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
		</body>
</html>

experiment.css

/* 
Parallax Experiment
Date: 2nd April 2009
Author: Paul Hayes
*/

#background {
background: url('../images/foreground.png') 5% 5%, url('../images/midground.png') 50% 50%, url('../images/background.png') 90% 110%;
top: 90px;
left: 0;
right: 0;
bottom: 0;
position: fixed;
-webkit-transition: left 300s linear;
-moz-transition: left 300s linear;
-o-transition: left 300s linear;
-ms-transition: left 300s linear;
transition: left 300s linear;
}

#experiment:target #background {
left: -5000px;
}

#experiment:hover #background {
left: -9999px;
}

#content {
margin: 3em 10em;
background-color: #333;
opacity: 0.95;
color: #ccc;
padding: 3em;
position: fixed;
border: 2px solid #666;
}

#content h2 {
margin: 1em 0;
font-weight: bold;
font-size:  26px;
}


图片:



xia


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值