Skip to content

Instantly share code, notes, and snippets.

@gamikun
Created October 30, 2015 01:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gamikun/6f6fcf793c1adf29b153 to your computer and use it in GitHub Desktop.
Save gamikun/6f6fcf793c1adf29b153 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<title>Mi fondo se mueve!</title>
<script type="text/javascript">
window.onload = function() {
document.onmousemove = function(e) {
var x = -(e.clientX/10);
var y = -(e.clientY/10);
this.body.style.backgroundPosition = x + 'px ' + y + 'px';
};
};
</script>
<style type="text/css">
body {
background: url('imagen.jpg');
}
#info {
width: 400px;
text-align: center;
background: #fff;
margin: 150px auto 0 auto;
padding: 30px;
border-radius: 5px;
}
</style>
</head>
<body>
<div id="info">
¡El fondo se mueve!
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment