css利用flex布局画骰子的六个面

主要是利用flex的一些特性来写的,掌握好flex基础,写出筛子的几个页面不是问题。
推荐去我写的一个博客中有flex的小练习 线上练习flex布局

html

<body>
    <div class="shaizi">
        <div class="top">
            <div class="box1 box">
                <span class="item"></span>
            </div>
            <div class="box2 box">
                <span class="item"></span>
                <span class="item"></span>
            </div>
            <div class="box3 box">
                <span class="item"></span>
                <span class="item"></span>
                <span class="item"></span>
            </div>
        </div>
        <div class="bottom">
            <div class="box4 box">
                <div class="box4_top">
                    <span class="item"></span>
                    <span class="item"></span>
                </div>
                <div class="box4_buttom">
                    <span class="item"></span>
                    <span class="item"></span>
                </div>
            </div>
            <div class="box5 box">
                <div class="box5_top">
                    <span class="item"></span>
                    <span class="item"></span>
                </div>
                <div class="box5_center">
                    <span class="item"></span>
                </div>
                <div class="box5_buttom">
                    <span class="item"></span>
                    <span class="item"></span>
                </div>
            </div>
            <div class="box6 box">
                <div class="box6_top">
                    <span class="item"></span>
                    <span class="item"></span>
                </div>
                <div class="box6_center">
                    <span class="item"></span>
                    <span class="item"></span>
                </div>
                <div class="box6_buttom">
                    <span class="item"></span>
                    <span class="item"></span>
                </div>
            </div>
        </div>
    </div>
</body>

css

<style>
    .shaizi {
        width: 1400px;
        height: 600px;
        margin: auto;
        border: 2px solid #ddd;
        border-radius: 10px;
        padding: 20px;
        display: flex;
        flex-wrap: wrap;
        /* flex-direction: column;; */
    }
    .item {
        display: block;
        width: 40px;
        height: 40px;
        border-radius: 50%;
        background-color: #666;
    }
    .box{
        width: 200px;
        height: 200px;
        border: 2px solid #ccc;
        border-radius: 10px;
        padding: 20px;
        display: flex;
    }
    .top {
        display: flex;
        width: 1400px;
        justify-content: space-around;
    }
    .bottom{
        display: flex;
        width: 1400px;
        justify-content: space-around;
    }
    .box1 {
        justify-content: center;
        align-items: center;
    }
    .box2 {
        justify-content: space-between;
        align-items: center;
    }
    .box3 {
        justify-content: space-between;
        /* 两端对齐 */
    }
    .box3 .item:nth-child(2) {
        align-self: center;
        /* 上下左右居中对齐 */
    }
    .box3 .item:nth-child(3) {
        align-self: flex-end;
        /* 尾对齐 */
    }
    .box4 {
         flex-direction: column;
         justify-content: space-between;
    }
    .box4_top{
        width: 200px;
        height: 100px;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }
    .box4_buttom{
        width: 200px;
        height: 100px;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }
    .box5{
        flex-direction: column;
        justify-content: space-between;
    }
    .box5_top{
        display: flex;
        justify-content: space-between;
    }
    .box5_center{
        display: flex;
        justify-content: center;
    }
    .box5_buttom{
        display: flex;
        justify-content: space-between;
    }
    .box6{
        flex-direction: column;
        justify-content: space-between;
    }
    .box6_top{
        display: flex;
        justify-content: space-between;
    }
    .box6_center{
        display: flex;
        justify-content: space-between;
    }
    .box6_buttom{
        display: flex;
        justify-content: space-between;
    }
</style>

效果

相关文章

一:display:flex布局display:flex是一种布局方式。它即可以...
1. flex设置元素垂直居中对齐在之前的一篇文章中记载过如何...
移动端开发知识点pc端软件和移动端apppc端软件是什么,有哪些...
最近挺忙的,准备考试,还有其他的事,没时间研究东西,快周...
display:flex;把容器设置为弹性盒模型(设置为弹性盒模型之后...
我在网页上运行了一个Flex应用程序,我想使用Command←组合键...