Skip to content

Instantly share code, notes, and snippets.

@h4
Created April 3, 2012 13:09
Show Gist options
  • Save h4/2291863 to your computer and use it in GitHub Desktop.
Save h4/2291863 to your computer and use it in GitHub Desktop.
Анимированый блок
<!DOCTYPE html>
<html>
<head>
<title>Анимированный блок</title>
<style>
#box {
height: 50px;
width: 100px;
background: #F00;
position: absolute;
left: 0;
}
</style>
<script>
function moveEl(el, direction) {
if (isNaN(parseInt(el.style.left))) {
el.style.left = 0;
}
el.style.left = parseInt(el.style.left) + 10 + "px";
}
window.onload = function() {
el = document.getElementById("box");
t = setInterval(function() { moveEl(el); }, 100);
}
</script>
</head>
<body>
<div id="box"></div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment