弹性盒布局实例

  今天给大家搞一个弹性盒布局的实例,最近一直在复习一些基础的东西,所以一直会跟大家分享一些基础的东西

  说实话,最近感觉被掏空了,别问我为什么,谁去保健谁知道,哈哈,注意安全,好了步入正题,今天用弹性盒写了一个小例子,

  关于弹性盒的一些基础我就不列举了,大家有需要可以去   http://www.ruanyifeng.com/blog/2015/07/flex-grammar.html    阮一峰大佬的网站去看看

  他已经写的非常详细了,好,那我们来直接举栗

  

  老规矩,我还是把代码扔上来,大家可以自己拉下去玩一下

  

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        *{margin: 0;padding: 0}
        /* box的样式 */
        .box{
            height: 300px;
            width: 100%;
            background: oldlace;
            margin: 150px auto;
            display: flex;
            justify-content: space-around;
            align-items: center;
        }
        /* box下div的样式 */
        .box>div{
            width: 130px;
            height: 130px;
            background-color: black;
            display: flex;
            padding: 20px;
        }
        /* span的样式 */
        span{
            height: 25px;
            width: 25px;
            background-color: white;
            border-radius: 50%;
        }
        /*写筛子*/

        /* 第一个筛子面 */
        .a1{
            /* 控制主轴的排列 */
            justify-content: center;
            /* 控制副轴的排列 */
            align-items: center;
        }

        /* 第二个筛子面 */
        .a2{
            /* 将主轴改变为列 */
            flex-direction: column;

            justify-content: space-around;
            align-items: center
        }
        /* 第三个筛子面 */
        .a3{
            justify-content: space-between;
        }
        .a3>span:nth-of-type(2){
            align-self: center;
        }
        .a3>span:nth-of-type(3){
            align-self: flex-end;
        }
        /* 第四个筛子面 */
        .a4{
            justify-content: space-around;
        }
        .a4>div{
            display: flex;
            flex-direction: column;
            justify-content: space-around;
        }

        /* 第五个筛子面 */
        .a5{
            justify-content: space-around;
        }
        .a5>div{
            display: flex;
            flex-direction: column;
            justify-content:space-around;
        }

        /*第六个筛子面*/
        .a6{
            justify-content: space-around;
        }
        .a6>div{
            display:flex;
            flex-direction: column;
            justify-content: space-around;
        }

    </style>
</head>
<body>
    <div class="box">
        <!-- 第一个div -->
        <div class="a1"><span></span></div>
        <!-- 第二个div -->
        <div class="a2"><span></span><span></span></div>
        <!-- 第三个div -->
        <div class="a3"><span></span><span></span><span></span></div>
        <!-- 第四个div -->
        <div class="a4">
                <div><span></span><span></span></div>
                <div><span></span><span></span></div>
           </div>
        <!-- 第五个div -->
        <div class="a5">
                <div><span></span><span></span></div>
                <div><span></span></div>
                <div><span></span><span></span></div>
        </div>
        <!-- 第六个div -->
        <div class="a6">
                <div><span></span><span></span><span></span></div>
                <div><span></span><span></span><span></span></div>
        </div>
    </div>
</body>
</html>

       哇,这木长的代码,你竟然能看到这里,太感动了,抓紧联系我好吧,我带你保健去


更多专业前端知识,请上 【猿2048】www.mk2048.com
  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值