css3实现立方体,并且自转效果_html/css_WEB-ITnose

WBOY
Release: 2016-06-24 12:07:39
Original
969 people have browsed it

先是HTML 一个父div包含四个绝对定位的div 

     
       
1
       
2
       
3
       
4
     
  
  


首先,一个静态的立方体 

.face:nth-child(1) {     -webkit-transform: /*rotateY(0deg)*/ translateZ(2.5em /* half the side length, 5em in this case */);   }   .face:nth-child(2) {     -webkit-transform: rotateY( 90deg)   translateZ(2.5em);   }   .face:nth-child(3) {     -webkit-transform: rotateY(180deg)  translateZ(2.5em);   }   .face:nth-child(4) {     -webkit-transform: rotateY(270deg)   translateZ(2.5em);   }  


让立方体转起来 

.cube--ani {     -webkit-animation: rot 4s linear infinite;   }   @-webkit-keyframes rot {     to {  -webkit-transform: rotateY(-330deg) rotateX(370deg); }   }  


这里定义了一个动画 rot

 

从起始位置转动到 Y轴-330deg X轴370deg

并且循环无限次,每次4s

OK!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!