当前位置 博文首页 > 文章内容

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

    作者: 栏目:未分类 时间:2020-09-24 10:03:23

    本站于2023年9月4日。收到“大连君*****咨询有限公司”通知
    说我们IIS7站长博客,有一篇博文用了他们的图片。
    要求我们给他们一张图片6000元。要不然法院告我们

    为避免不必要的麻烦,IIS7站长博客,全站内容图片下架、并积极应诉
    博文内容全部不再显示,请需要相关资讯的站长朋友到必应搜索。谢谢!

    另祝:版权碰瓷诈骗团伙,早日弃暗投明。

    相关新闻:借版权之名、行诈骗之实,周某因犯诈骗罪被判处有期徒刑十一年六个月

    叹!百花齐放的时代,渐行渐远!



    主要是利用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>
    

    效果