猿问

如何css制作3d旋转立方体效果

如何css制作3d旋转立方体效果


肥皂起泡泡
浏览 523回答 3
3回答

饮歌长啸

<style> &nbsp; &nbsp;*{ &nbsp; &nbsp;margin:0px; &nbsp; &nbsp;padding:0px; &nbsp; &nbsp;} &nbsp; &nbsp;.box{ &nbsp; &nbsp;width:200px; &nbsp; &nbsp;margin:200px auto; &nbsp; &nbsp;perspective:800px; &nbsp; &nbsp;} &nbsp; &nbsp;.cube{ &nbsp; &nbsp;position:relative; &nbsp; &nbsp;width:200px;height:200px; &nbsp; &nbsp;transform-style:preserve-3d; &nbsp; &nbsp;transform:rotateY(0deg); &nbsp; &nbsp;transition:2s; &nbsp; &nbsp;} &nbsp; &nbsp;.cube div{ &nbsp; &nbsp;position:absolute; &nbsp; &nbsp;width:200px; &nbsp; &nbsp;height:200px; &nbsp; &nbsp;border:2px solid red; &nbsp; &nbsp;text-align:center; &nbsp; &nbsp;line-height:200px; &nbsp; &nbsp;font-size:30px; &nbsp; &nbsp;opacity:0.5; &nbsp; &nbsp;} &nbsp; &nbsp;.cube div:nth-child(1){ &nbsp; &nbsp;/*先旋转90度再往相应的方向移动*/ &nbsp; &nbsp;transform:rotateX(90deg) translateZ(102px); &nbsp; &nbsp;background:#ff33ff; &nbsp; &nbsp;} &nbsp; &nbsp;.cube div:nth-child(2){ &nbsp; &nbsp;transform:rotateX(-90deg) translateZ(102px); &nbsp; &nbsp;background:#99ff99; &nbsp; &nbsp;} &nbsp; &nbsp;.cube div:nth-child(3){ &nbsp; &nbsp;transform:translateZ(102px); &nbsp; &nbsp;background:#ccff33; &nbsp; &nbsp;} &nbsp; &nbsp;.cube div:nth-child(4){ &nbsp; &nbsp;transform:translateZ(-102px); &nbsp; &nbsp;background:#336699; &nbsp; &nbsp;} &nbsp; &nbsp;.cube div:nth-child(5){ &nbsp; &nbsp;transform:rotateY(90deg) translateZ(102px); &nbsp; &nbsp;background:#990033; &nbsp; &nbsp;} &nbsp; &nbsp;.cube div:nth-child(6){ &nbsp; &nbsp;transform:rotateY(-90deg) translateZ(102px); &nbsp; &nbsp;background:#666633; &nbsp; &nbsp;} &nbsp; &nbsp;.cube:hover{ &nbsp; &nbsp;transform:rotateY(360deg); &nbsp; &nbsp;} &nbsp; &nbsp;</style> &nbsp; &nbsp;</head> &nbsp; &nbsp;<body> &nbsp; &nbsp;<div class="box"> &nbsp; &nbsp;<div class="cube"> &nbsp; &nbsp;<div>上</div> &nbsp; &nbsp;<div>下</div> &nbsp; &nbsp;<div>前</div> &nbsp; &nbsp;<div>后</div> &nbsp; &nbsp;<div>左</div> &nbsp; &nbsp;<div>右</div> &nbsp; &nbsp;</div> &nbsp; &nbsp;</div> &nbsp; &nbsp;</body> &nbsp; &nbsp;资源:http://www.xuniyicheng.com/article/6.jsp
随时随地看视频慕课网APP

相关分类

CSS3
我要回答