博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
弹性盒制作骰子
阅读量:4677 次
发布时间:2019-06-09

本文共 2372 字,大约阅读时间需要 7 分钟。

html样式

一、二、三这三个点数很容易,div里面有几个点就加几个span。到了四,就需要进行分组。四分两组,五和六分三组

css代码

先写容器骰子的样式

body{        display: flex;        justify-content: space-around;        align-items: center;    }    div{        width: 100px;        height: 100px;        background: #e7e7e7;        padding: 4px;        box-shadow: inset 0 5px white, inset 0 -5px #bbb, inset 5px 0         #d7d7d7, inset -5px 0 #d7d7d7;         border-radius: 10px;        }

接下来写点数span的样式,写一、二、三点。##先把骰子的六个面在游览器水平居中排列:六个div,给它们设置相同的样式。同时body要把它转换成弹性盒。让六个div在body弹性盒中,沿着主轴(x轴)自由分配,同时在侧轴(y轴)居中。

span{        width: 30px;        height: 30px;        background: #000;        border-radius: 15px;    }    div:nth-child(1){        display: flex;        justify-content: center;        align-items: center;    }    div:nth-child(2){        display: flex;        justify-content: space-between;    }    div:nth-child(2) span:nth-child(2){                align-self: flex-end;    }    div:nth-child(3){        display: flex;        justify-content: space-between;    }    div:nth-child(3) span:nth-child(2){        align-self: center;    }    div:nth-child(3) span:nth-child(3){        align-self: flex-end;    }

第四点有两种写法。不论哪一种,article的样式都一样

article{            display: flex;            justify-content: space-between;}

第一种

div:nth-child(4){    display: flex;    justify-content: space-between;}div:nth-child(4) article{    display: flex;    flex-direction: column;    justify-content: space-between;}

第二种

div:nth-child(4){        display: flex;        flex-direction: column;        justify-content: space-between;    }

五和六的代码

div:nth-child(5){            display: flex;            flex-direction: column;         }        div:nth-child(5) article:nth-child(2){            justify-content: center;        }        div:nth-child(6){            display: flex;            flex-direction: column;        }

最后的效果如下图所示

![](https://img2018.cnblogs.com/blog/1586176/201901/1586176-20190119113448916-200959925.jpg)

转载于:https://www.cnblogs.com/web-learning/p/10265137.html

你可能感兴趣的文章
【BZOJ5005】乒乓游戏 [线段树][并查集]
查看>>
前端页面数据埋点、分析和参考
查看>>
NBear简介与使用图解
查看>>
ng-app一些使用
查看>>
sql 查询目标数据库中所有的表以其关键信息
查看>>
C# 高效率创建字符串类(StringBuilder)
查看>>
sql server 符号函数sign
查看>>
bzoj 4337 树的同构
查看>>
OPENQUERY用法以及使用需要注意的地方
查看>>
1001. Extending MyPoint class
查看>>
js使用showModalDialog,弹出一个自适应大小窗口
查看>>
[poj 3436]最大流+输出结果每条边流量
查看>>
webpack的安装
查看>>
字符流Reader和Writer
查看>>
【校招面试 之 C/C++】第33题 C++ 11新特性(四)之STL容器
查看>>
Java替代C语言的可能性
查看>>
android ListView中CheckBox错位的解决
查看>>
linux下的mongodb数据库原生操作
查看>>
BNUOJ 1268 PIGS
查看>>
菜鸟的MySQL学习笔记(三)
查看>>