杰网资源 Design By www.escxy.com
本文实例为大家分享了CSS3 3D 位移translate效果实例,供大家参考,具体内容如下
效果图:
示例代码:
XML/HTML Code复制内容到剪贴板- <!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;
- transition: background-color 1s;
- -webkit-transition: background-color 1s;
- }
- #block:hover {
- background-color: purple;
- }
- #op {
- text-align: center;
- }
- #op input {
- width: 800px;
- }
- </style>
- <script>
- function translateall() {
- var x = document.getElementById("translateX").value;
- var y = document.getElementById("translateY").value;
- var z = document.getElementById("translateZ").value;
- document.getElementById("block").style.webkitTransform = "translate3d(" + x + "px," + y + "px," + z + "px)";
- document.getElementById("translatex-span").innerText = x;
- document.getElementById("translatey-span").innerText = y;
- document.getElementById("translatez-span").innerText = z;
- }
- </script>
- </head>
- <body>
- <div id="experiment">
- <div id="block">
- </div>
- </div>
- <div id="op">
- <p>translate x: <span id="translatex-span">0</span>px</p>
- <input type="range" min="-360" max="360" id="translateX" value="0" class="range-control" onmousemove="translateall()"/><br/>
- <p>translate y: <span id="translatey-span">0</span>px</p>
- <input type="range" min="-360" max="360" id="translateY" value="0" class="range-control" onmousemove="translateall()"/><br/>
- <p>translate z: <span id="translatez-span">0</span>px</p>
- <input type="range" min="-360" max="360" id="translateZ" value="0" class="range-control" onmousemove="translateall()"/><br/>
- </div>
- </body>
- </html>
以上就是本文的全部内容,希望对大家的学习有所帮助。
杰网资源 Design By www.escxy.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
杰网资源 Design By www.escxy.com
暂无评论...