CSS3 3D旋轉rotate效果的使用介紹

來源:互聯網
上載者:User
這篇文章主要為大家詳細介紹了CSS3 3D旋轉rotate效果執行個體,具有一定的參考價值,感興趣的小夥伴們可以參考一下

本文執行個體為大家分享了CSS3 3D旋轉rotate效果執行個體,供大家參考,具體內容如下

範例程式碼

<!DOCTYPE html><html lang="en"><head>    <meta charset="UTF-8">    <title>3D旋轉的Demo</title>    <style>        #experiment {                 -webkit-perspective: 800;                 -webkit-perspective-origin: 50% 50%;                 -webkit-transform-style: -webkit-preserve-3d;             }             #block {                 width: 200px;                 height: 200px;                 background-color: pink;                 margin: 100px auto;                 -webkit-transition: background-color 3s;             }             #block:hover {                 background-color: purple;             }             #ep {                 text-align: center;             }             #ep input {                 width: 800px;             }         </style>    <script>        function rotate() {                 var x = document.getElementById("rotateX").value;                 var y = document.getElementById("rotateY").value;                 var z = document.getElementById("rotateZ").value;                 document.getElementById("block").style.webkitTransform = "rotateX(" + x + "deg) rotateY(" + y + "deg) rotateZ(" + z + "deg)";                 document.getElementById("degx-span").innerText = x;                 document.getElementById("degy-span").innerText = y;                 document.getElementById("degz-span").innerText = z;             }         </script></head><body>    <p id="experiment">        <p id="block"></p>    </p>    <p id="ep">        <p>rotate x: <span id="degx-span">0</span>deg</p>        <input type="range" min="-360" max="360" id="rotateX" value="0" class="range-control" onmousemove="rotate()"/><br/>        <p>rotate y: <span id="degy-span">0</span>deg</p>        <input type="range" min="-360" max="360" id="rotateY" value="0" class="range-control" onmousemove="rotate()"/><br/>        <p>rotate z: <span id="degz-span">0</span>deg</p>        <input type="range" min="-360" max="360" id="rotateZ" value="0" class="range-control" onmousemove="rotate()"/><br/>    </p></body></html>

以上就是本文的全部內容,希望對大家的學習有所協助,更多相關內容請關注topic.alibabacloud.com!

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.