如何使用JavaScript将2D或3D转换应用于元素?
使用JavaScript中的transform属性可以将2D或3D转换设置为元素。如果要将值旋转到60度,则将其设置为旋转(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>热门推荐
10 感恩护士贺卡祝福语简短
11 反乡送行祝福语简短
12 学生班级群祝福语简短
13 爸妈姑姑相聚祝福语简短
14 简短祝福语开业大全
15 退休祝福语事业文案简短
16 端午祝福语简短送老师
17 新年日文祝福语大全简短
18 干杯生日祝福语简短独特