如何使用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 婆婆高寿祝福语大全简短