ใช้ แปลง คุณสมบัติใน JavaScript เพื่อตั้งค่าการแปลง 2D หรือ 3D เป็นองค์ประกอบ ตั้งค่าให้หมุน (60deg) หากต้องการหมุนเป็น 60 องศา ฯลฯ
ตัวอย่าง
คุณสามารถลองเรียกใช้โค้ดต่อไปนี้เพื่อใช้การแปลง 2D หรือ 3D กับองค์ประกอบด้วย JavaScript -
<!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>