css3 一个简单的静态立方体
Posted 两只小蜜蜂啊
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了css3 一个简单的静态立方体相关的知识,希望对你有一定的参考价值。
<meta charset="utf8"> <style> .cube { position: absolute; left: 50%; top: 250px; } .rightFace,.leftFace,.topFace div{ position: absolute; padding: 10px; width: 180px; height: 180px; } .leftFace { transform: skew(0deg, 30deg); background-color: #ccc; } .rightFace { transform: skew(0deg, -30deg); background-color: #ddd; left: 200px; } .topFace { transform: rotate(60deg); } .topFace div { transform: skew(0deg, -30deg) scale(1, 1.16); background-color: #eee; font-size: 0.862em; top: -300px; left: -48px; } </style> <div class="cube"> <div class="topFace"> <div> 上 </div> </div> <div class="leftFace"> 左 </div> <div class="rightFace"> 右 </div> </div>
原版
<meta charset="utf8"> <style> /* Cube Experiment Date: 26th March 2009 Author: Paul Hayes */ #experiment { min-height: 500px; } .cube { position: absolute; left: 50%; top: 250px; margin-left: -200px; } .cube p { line-height: 14px; font-size: 12px; } .cube h2 { font-weight: bold; } .rightFace, .leftFace, .topFace div { padding: 10px; width: 180px; height: 180px; } .rightFace, .leftFace, .topFace { position: absolute; } .leftFace { -webkit-transform: skew(0deg, 30deg); -moz-transform: skew(0deg, 30deg); -o-transform: skew(0deg, 30deg); -ms-transform: skew(0deg, 30deg); transform: skew(0deg, 30deg); background-color: #ccc; } .rightFace { -webkit-transform: skew(0deg, -30deg); -moz-transform: skew(0deg, -30deg); -o-transform: skew(0deg, -30deg); -ms-transform: skew(0deg, -30deg); transform: skew(0deg, -30deg); background-color: #ddd; left: 200px; } .topFace div { -webkit-transform: skew(0deg, -30deg) scale(1, 1.16); -moz-transform: skew(0deg, -30deg) scale(1, 1.16); -o-transform: skew(0deg, -30deg) scale(1, 1.16); -ms-transform: skew(0deg, -30deg) scale(1, 1.16); transform: skew(0deg, -30deg) scale(1, 1.16); background-color: #eee; font-size: 0.862em; } .topFace { -webkit-transform: rotate(60deg); -moz-transform: rotate(60deg); -o-transform: rotate(60deg); -ms-transform: rotate(60deg); transform: rotate(60deg); top: -158px; left: 100px; } /* Optional WebKit Animations */ /* .rightFace { -webkit-transition: -webkit-transform 1s linear; } .leftFace { -webkit-transition: -webkit-transform 1s linear; } .topFace { -webkit-transition: -webkit-transform 1s linear; } .cube:hover .rightFace { -webkit-transform: skew(0deg, -30deg) translate(100px, 100px); } .cube:hover .leftFace { -webkit-transform: skew(0deg, 30deg) translate(-100px, 100px); } .cube:hover .topFace { -webkit-transform: rotate(60deg) translate(-50px, -50px); } /* Video */ .cube video { left: -20px; top: -20px; position: relative; } .cube div.rightFace video { left: -301px; top: -35px; opacity: 0.9; } .cube div.leftFace video { opacity: 0.7; top: -35px; left: -100px; } .cube div.rightFace, .cube div.leftFace { overflow: hidden; } .cube div.topFace.video div { background-color: #000; color: #fff; } </style> <div id="experiment"> <div class="cube"> <div class="topFace"><div> <h2>Top cube face</h2> <p>The top face is nested in an extra div tag to give correct rotation of skewed rectangle.</p> <p>This face is also scaled, so the font size has been reduced to accommodate.</p> </div></div> <div class="leftFace"> <h2>Left cube face</h2> <p>Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p> </div> <div class="rightFace"> <h2>Right cube face</h2> <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p> </div> </div> </div>
地址
http://paulrhayes.com/experiments/cube/multiCubes.html
http://paulrhayes.com/experiments/cube/index.html
以上是关于css3 一个简单的静态立方体的主要内容,如果未能解决你的问题,请参考以下文章