Last active
January 25, 2019 13:40
-
-
Save afrontend/42d306ae2f8c0831a748d9b25f5be299 to your computer and use it in GitHub Desktop.
JavaScript 만으로 네모 굴리기, https://agvim.wordpress.com/2019/01/25/roll-a-square-with-the-javascript/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>네모 굴리기 - HTML, CSS 사용한 버전</title> | |
<meta charset="utf-8" /> | |
<style> | |
.square { | |
width: 100px; | |
height: 100px; | |
border: 1px solid red; | |
} | |
.square.move { | |
margin-left: 400px; | |
transition: 4s; | |
transform: rotate(360deg) | |
} | |
</style> | |
</head> | |
<body> | |
<div class="square"></div> | |
<script> | |
setTimeout(function() { | |
document.querySelector(".square").className += ' move'; | |
}, 2000); | |
</script> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>네모 굴리기 - jQuery 사용한 버전</title> | |
<meta charset="utf-8" /> | |
<script src="https://code.jquery.com/jquery-2.2.4.min.js"></script> | |
</head> | |
<body> | |
<script> | |
$("body").append("<div class='square'></div>"); | |
var style = { | |
"width": "100px", | |
"height": "100px", | |
"border": "1px solid red" | |
}; | |
$(".square").css(style); | |
setTimeout(function() { | |
var moveStyle = { | |
"margin-left": "400px", | |
"transition": "4s", | |
"transform": "rotate(360deg)" | |
}; | |
$(".square").css(moveStyle); | |
}, 2000); | |
</script> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>네모 굴리기 - jQuery 사용하지 않은 버전</title> | |
<meta charset="utf-8" /> | |
<style> | |
</style> | |
</head> | |
<body> | |
<script> | |
var node = document.createElement("div"); | |
node.className = 'square'; | |
var elements = document.getElementsByTagName("body"); | |
elements[0].appendChild(node); | |
node.style.width = "100px"; | |
node.style.height = "100px"; | |
node.style.border = "1px solid red"; | |
setTimeout(function() { | |
node.style.marginLeft = "400px"; | |
node.style.transition = "4s"; | |
node.style.transform = "rotate(360deg)"; | |
}, 2000); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment