时间:2021-07-01 10:21:17 帮助过:54人阅读
废话不多说了,直接给大家贴代码了,具体代码如下所示:
<!DOCTYPE html> <html> <head> <meta charset=utf-8 /> <title>zimv-css 3d ball</title> </head> <style> body{ padding: 100px 0 0 150px; } </style> <body> <p class="wrapper"> <p class="box" id="circles"> </p> </p> <style> .wrapper{ animation: rotate 3s infinite linear alternate; transform-style: preserve-3d; width: 100px; height: 100px; margin:150px 0 0 150px; } .box{ width: 100%; height: 100%; position: relative; transform-style: preserve-3d; transform: rotateX(-30deg) rotateY(45deg); } .circle{ border-radius: 50%; width: 100%; height: 100%; position: absolute; left: 0; top: 0; border: 1px solid red; } @keyframes rotate { 0% { transform: rotateZ(0deg); } 50%{ transform: rotateZ(360deg); } 100% { transform: rotateZ(360deg) rotateX(180deg); } } </style> <script> let cir = document.getElementById('circles'); for(let i=0;i<180;i++){ let p = document.createElement('p'); p.style = `transform: rotateX(${i}deg);border: 1px solid rgba(200,200,200,1)`; p.className = 'circle'; cir.appendChild(p); } </script> </body> </html>
以上就是对的全部介绍,如果您想了解更多有关CSS视频教程,请关注PHP中文网。
以上就是CSS 3D实现旋转球是如何实现的?(代码案例)的详细内容,更多请关注Gxl网其它相关文章!