변환 사용 2D 또는 3D 변환을 요소로 설정하려면 JavaScript의 속성을 사용하십시오. 회전할 값(60deg)을 설정하고, 60도 등으로 회전하려면
예시
다음 코드를 실행하여 JavaScript를 사용하여 요소에 2D 또는 3D 변환을 구현할 수 있습니다. −
<!DOCTYPE html>
<html>
<head>
<style>
#box {
margin-left: 20px;
border: 2px solid black;
width: 300px;
height: 250px;
background-color: gray;
color: white;
}
</style>
</head>
<body>
<button onclick = "display()">Apply</button>
<div id = "box"><p>Demo Text</p></div>
<script>
function display() {
document.getElementById("box").style.transform = "rotate(60deg)";
}
</script>
</body>
</html>