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