Skip to content

Instantly share code, notes, and snippets.

@pedroppinheiro
Created October 11, 2018 18:10
Show Gist options
  • Select an option

  • Save pedroppinheiro/726bf88634106e0a720fb76d4e38c7cd to your computer and use it in GitHub Desktop.

Select an option

Save pedroppinheiro/726bf88634106e0a720fb76d4e38c7cd to your computer and use it in GitHub Desktop.
youmightnotneedjquery
<!DOCTYPE html>
<html>
<head>
<style>
#square {
width: 100px;
height: 100px;
background: red;
position: relative;
}
.animate-square {
animation: mymove 5s infinite;
}
/* Standard syntax */
@keyframes mymove {
0% {top: 0px;}
25% {top: 200px;}
75% {top: 50px}
100% {top: 100px;}
}
</style>
</head>
<body>
<h1>The @keyframes Rule</h1>
<p><strong>Note:</strong> The @keyframes rule is not supported in Internet Explorer 9 and earlier versions.</p>
<button id="btn">Start</button>
<div id="square"></div>
<script>
const button = document.getElementById('btn');
button.addEventListener('click', (event) => {
console.log(event)
console.log(event.target.text)
event.srcElement.text = event.target.text === 'start' ? 'stop' : 'start'
const square = document.getElementById('square')
square.classList.toggle("animate-square");
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment