Here In This Html Tutorial We Will Create the Animation Using Html/Css/Javascript Code.
Here In This Blog We Will Create the Animation Using Html/Css/Javascript Code.
Here Is An Example Related To Topic Bellow....................
So Let Begin With Our Coding............
Step 1 :
<!DOCTYPE html>
<html>
<style>
#container {
width: 400px;
height: 400px;
position: relative;
background: yellow;
}
#animate {
width: 50px;
height: 50px;
position: absolute;
background-color: red;
}
</style>
<body>
<p>
<button onclick="myMove()">Click Me</button>
</p>
<div id ="container">
<div id ="animate"></div>
</div>
<script>
function myMove() {
var elem = document.getElementById("animate");
var pos = 0;
var id = setInterval(frame, 5);
function frame() {
if (pos == 350) {
clearInterval(id);
} else {
pos++;
elem.style.top = pos + 'px';
elem.style.left = pos + 'px';
}
}
}
</script>
</body>
</html>
HTML stands for Hyper Text Markup
Language. It is the
standard markup language used for creating
web pages and web applications. It forms a
triology of technologies for the World Wide Web with Cascading Style
Sheets
(CSS) and JavaScript. HTML
elements are the building blocks of HTML pages. HTML elements are represented by
using tags, written using angle brackets. For e.g.
<html> </html>, <head></head> and so on. These tags are
used to interpret the content of the page.
Here In This Blog We Will Create the Animation Using Html/Css/Javascript Code.
Here Is An Example Related To Topic Bellow....................
So Let Begin With Our Coding............
Step 1 :
<!DOCTYPE html>
<html>
<style>
#container {
width: 400px;
height: 400px;
position: relative;
background: yellow;
}
#animate {
width: 50px;
height: 50px;
position: absolute;
background-color: red;
}
</style>
<body>
<p>
<button onclick="myMove()">Click Me</button>
</p>
<div id ="container">
<div id ="animate"></div>
</div>
<script>
function myMove() {
var elem = document.getElementById("animate");
var pos = 0;
var id = setInterval(frame, 5);
function frame() {
if (pos == 350) {
clearInterval(id);
} else {
pos++;
elem.style.top = pos + 'px';
elem.style.left = pos + 'px';
}
}
}
</script>
</body>
</html>
Output :
Good
ReplyDelete