立体骰子

效果图

3D骰子.gif

代码

直接上代码:

<!DOCTYPE html>
<html lang="en">
 <head>
 <title>demo03</title>
 <meta charset="UTF-8">
 <meta name="viewport" content="width=device-width, initial-scale=1">
 <style>
 *{
 margin: 0px;
 padding: 0px;
 /* opacity: .8;   // 不能在这里设置透明度啊~~ */
 }
 body{
 background-color: black;
 }
 ul#list{
 width: 150px;
 height: 150px;

 list-style: none;
 position: relative;

 margin: 100px auto;

 transition: 6s;
 transform-style: preserve-3d;
 }

 ul#list:hover{
 transform: rotateX(450deg) rotateY(450deg);
 }

 ul#list li{
 width: 100%;
 height: 100%;
 background-color: snow;
 border-radius: 4px;
 opacity: .6;
 box-sizing: border-box;
 padding: 15px;
 position: absolute;
 top: 0px;

 display: flex;
 }

 /* 设置点数的样式 */
 span{
 width: 35px;
 height: 35px;
 border-radius: 40px;
 background-color: snow;
 box-shadow: 0px 0px 20px rgba(125, 125, 125, .8)
 }

 ul#list li:nth-child(1){
 background-color: skyblue;
 transform: rotateX(0deg) translateZ(75px);

 justify-content: center;
 align-items: center;
 }

 ul#list li:nth-child(2){
 background-color: salmon;

 transform: rotateX(-90deg) translateZ(75px);

 justify-content: space-between;
 }
 ul#list li:nth-child(2) span:nth-child(2){
 align-self: flex-end;
 }

 ul#list li:nth-child(3){
 background-color: sandybrown;

 transform: rotateX(-180deg) translateZ(75px);

 justify-content: space-between;
 }
 ul#list li:nth-child(3) span:nth-child(2){
 align-self: center;
 }
 ul#list li:nth-child(3) span:nth-child(3){
 align-self: flex-end;
 }

 ul#list li:nth-child(4){
 background-color: fuchsia;

 transform: rotateX(90deg) translateZ(75px);

 flex-wrap: wrap;
 }
 ul#list li:nth-child(4) div{
 flex-basis: 100%;
 display: flex;

 justify-content: space-between;
 align-self: center;
 }

 ul#list li:nth-child(5){
 background-color: aquamarine;

 transform: rotateY(90deg) translateZ(75px);

 display: flex;
 flex-direction: column;
 }
 ul#list li:nth-child(5) div{
 flex-basis: 100%;
 display: flex;
 }
 ul#list li:nth-child(5) div:nth-child(1){
 justify-content: space-between;
 }
 ul#list li:nth-child(5) div:nth-child(2){
 justify-content:center;
 }
 ul#list li:nth-child(5) div:nth-child(3){
 justify-content: space-between;
 }

 ul#list li:nth-child(6){
 background-color: firebrick;

 transform: rotateY(-90deg) translateZ(75px);

 display: flex;
 flex-wrap: wrap;
 }
 ul#list li:nth-child(6) div{
 flex-basis: 100%;
 display: flex;
 justify-content: space-between;
 }
 ul#list li:nth-child(6) div:nth-child(2){
 align-self: center;
 }
 ul#list li:nth-child(6) div:nth-child(3){
 align-self: flex-end;
 }
 </style>
 </head>
 <body>
 <ul id="list">
 <li>
 <span></span>
 </li>
 <li>
 <span></span>
 <span></span>
 </li>
 <li>
 <span></span>
 <span></span>
 <span></span>
 </li>
 <li>
 <div>
 <span></span>
 <span></span>
 </div>
 <div>
 <span></span>
 <span></span>
 </div>
 </li>
 <li>
 <div>
 <span></span>
 <span></span>
 </div>
 <div>
 <span></span>
 </div>
 <div>
 <span></span>
 <span></span>
 </div>
 </li>
 <li>
 <div>
 <span></span>
 <span></span>
 <span></span>
 </div>
 <div>
 <span></span>
 <span></span>
 <span></span>
 </div>
 <div>
 <span></span>
 <span></span>
 <span></span>
 </div>
 </li>
 </ul>
 </body>
</html></pre>
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • 1、通过CocoaPods安装项目名称项目信息 AFNetworking网络请求组件 FMDB本地数据库组件 SD...
    阳明AI阅读 16,380评论 3 119
  • Android 自定义View的各种姿势1 Activity的显示之ViewRootImpl详解 Activity...
    passiontim阅读 180,425评论 25 708
  • 属性 声明一个属性: @property(nonatomic, strong) NSString *myStrin...
    ANN_12阅读 450评论 0 0
  • 昨夜3点醒了,然后看着远处的高速公路。旅途?
    三个梦阅读 386评论 0 0
  • 时针在不停的走 我被它无情的打在头顶 忽然发现我已经站在时间下啜泣 用尽所有力气也无法将岁月的痕迹遮盖 叶子又绿了...
    田萍阅读 385评论 0 2

友情链接更多精彩内容