概述 :
Css3d绘制一个卡通公交车 css3可以做一些很炫的3D效果,不过如果想绘制复杂点的图形的话还是不现实的,就比如曲面。但是通常情况下是做一些普通的特效是足够了。
css3可以做一些很炫的3D效果,不过如果想绘制复杂点的图形的话还是不现实的,就比如曲面。但是通常情况下是做一些普通的特效是足够了。
HTML
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | < div class = "stage" > < div class = "warp" > < div class = "box" > < div class = "face top" ></ div > < div class = "face bottom" > </ div > < div class = "face front" > < div class = "window" > < div class = "glass" ></ div > </ div > </ div > < div class = "face back" > < div class = "window" > < div class = "glass" ></ div > </ div > </ div > < div class = "face left" > < div class = "wheel" > < div class = "wheel-front" > </ div > < div class = "wheel-back" > </ div > </ div > </ div > < div class = "face right" > < div class = "wheel" > < div class = "wheel-front" > </ div > < div class = "wheel-back" > </ div > </ div > </ div > < div class = "wheel-width left-front" ></ div > < div class = "wheel-width left-back" ></ div > < div class = "wheel-width right-front" ></ div > < div class = "wheel-width right-back" ></ div > < div class = "wheel-in left-front-in" ></ div > < div class = "wheel-in left-back-in" ></ div > < div class = "wheel-in right-front-in" ></ div > < div class = "wheel-in right-back-in" ></ div > </ div > </ div > </ div > |
css
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 | .warp { width : 400px ; margin : 5 rem auto ; } .box { position : relative ; width : 400px ; height : 400px ; -webkit-transform-style:preserve -3 d; transform-style:preserve -3 d; transition:transform 2 s; transform:rotateY( 220 deg); -webkit-animation:go 8 s linear infinite; -o-animation:go 8 s linear infinite; animation:go 8 s linear infinite; -webkit-animation-play-state:running; -o-animation-play-state:running; animation-play-state:running; } @-webkit-keyframes go { 0% { -webkit-transform:rotateY( 0 deg); -webkit-transform-origin: center center ; } 100% { -webkit-transform:rotateY( 360 deg); -webkit-transform-origin: center center ; } }@-moz-keyframes go { 0% { -moz-transform:rotateY( 0 deg); -webkit-transform-origin: center center ; } 100% { -moz-transform:rotateY( 360 deg); -webkit-transform-origin: center center ; } }.box:hover { animation-play-state:paused; } .face { width : 600px ; height : 200px ; position : absolute ; transform-origin: 50% 50% ; /*backface-visibility:hidden; */ } . top { /*background-color:red; */ background-image : url (bustop.png); transform:translateY( -100px ) rotateX( 90 deg) rotateZ( 90 deg); } . bottom { /*background-color:green; */ background-image : url (busbotton.png); transform:translateY( 100px ) rotateX( 90 deg) rotateZ( 90 deg); } . left { /*background-color:blue; */ background-image : url (bus.png); -webkit-background- size : 100% ; background- size : 100% ; transform:translateX( -100px ) rotateY( 90 deg) rotateZ( 180 deg); } . right { background-image : url (busleft.png); /*background-color:pink; */ transform:translateX( 100px ) rotateY( 90 deg) rotateZ( 180 deg); } .front { width : 200px ; height : 200px ; transform:translateZ( 300px ) translateX( 200px ); /*background-color:gray; */ background-image : url (busfront.png); } .back { background-image : url (busback.png); width : 200px ; height : 200px ; /*background-color:lightblue; */ transform:translateZ( -300px ) translateX( 200px ); } /*轮子*/ .wheel { position : relative ; width : 100% ; } .wheel>div { width : 80px ; height : 80px ; background-color : #000 ; border-radius: 50% ; position : absolute ; /*background-image:url(wheel.png); */ } .wheel-front { bottom : -60px ; left : 100px ; } .wheel-back { bottom : -60px ; right : 100px ; } .wheel-width { position : absolute ; height : 100px ; width : 20px ; background-color : #000 ; /*border-radius:4px; */ } .left-front { transform:translateY( 120px ) translateX( 200px ) translateZ( 150px ) rotateY( 0 deg); } .left-back { transform:translateY( 120px ) translateX( 200px ) translateZ( -150px ) rotateY( 0 deg); } .right-front { transform:translateY( 120px ) translateX( 380px ) translateZ( 150px ) rotateY( 0 deg); } .right-back { transform:translateY( 120px ) translateX( 380px ) translateZ( -150px ) rotateY( 0 deg); } /*轮子内侧*/ .wheel-in { width : 80px ; height : 80px ; background-color : #000 ; border-radius: 50% ; position : absolute ; /*background-image:url(wheel.png); */ } .left-front-in { transform:translateY( 140px ) translateX( 180px ) translateZ( 150px ) rotateY( 90 deg); } .left-back-in { transform:translateY( 140px ) translateX( 180px ) translateZ( -150px ) rotateY( 90 deg); } .right-front-in { transform:translateY( 140px ) translateX( 340px ) translateZ( 150px ) rotateY( 90 deg); } .right-back-in { transform:translateY( 140px ) translateX( 340px ) translateZ( -150px ) rotateY( 90 deg); } /*车窗*/ .window { position : relative ; width : 100% ; } .glass { width : 160px ; height : 60px ; left : 20px ; top : 20px ; background-color : #9abfdc ; border-radius: 10px ; position : absolute ; } |
特别申明:
本站所有资源都是由网友投稿发布,或转载各大下载站,请自行检测软件的完整性!
本站所有资源仅供学习与参考,请勿用于商业用途,否则产生的一切后果将由您自己承担!
如有侵权请联系我们删除下架,联系方式:lei1294551502@163.com