Skip to content

Instantly share code, notes, and snippets.

@akakiev
Created April 1, 2017 10:57
Show Gist options
  • Save akakiev/f977f328a46465d005d45d39b174a994 to your computer and use it in GitHub Desktop.
Save akakiev/f977f328a46465d005d45d39b174a994 to your computer and use it in GitHub Desktop.
Hello world's move
<html>
<head>
<title>Coder</title>
</head>
<body class="page">
<div class="pagecontent">
<h1 id="box">Hello World</h1>
<p>My html goes here.</p>
<p>It is my first web-page.</p>
</div>
</body>
</html>
window.onload = function() {
//This code will run after your page loads
var pos=0;
var box=document.getElementById('box');
var t=setInterval(move, 10);
function move()
{
if(pos>=550)
{
clearInterval(t);
}
else
{
pos +=1;
box.style.left=pos+'px';
}
}
};
.pagecontent {
padding: 24px;
background-color:yellow;
}
.page{
background:blue;
}
p{
color:brown;
}
#box{
color:red;
position:absolute;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment