flex

flex布局小demo

 <style>
        body {
            display: flex;
            /*flex-direction: column;*/
            /*flex-wrap: wrap;*/
            /*flex-wrap: wrap-reverse;*/
            /*justify-content: flex-start;*/
            /*justify-content: flex-end;*/
            /*justify-content: center;*/
            /*justify-content: space-between;*/
            /*justify-content: space-around;*/
            /*align-items: center;*/
            /*align-items: flex-start;*/
            /*align-items: flex-end;*/
            /*align-items: baseline;*/
            /*align-content: center;*/
            /*align-content: space-between;*/
            /*align-content: space-around;*/
            /*align-content: stretch;*/
            width: 80vw;
            height: 80vh;
            margin: 2rem auto;
            border: 1px solid #000;
        }
        .box1 {
            display: flex;
            justify-content: center;
            align-items: center;
            /*order: 5;*/
            flex-shrink: 0;
            width:30%;
            height:30%;
            border: 1px solid #ff0000;
        }
        .box2 {
            width:60%;
            height: 60%;
            background-color: #ffff00;
        }
        .box3 {
            width: 30%;
            height:30%;
            background-color: #d58512;
        }
        .box4 {
            width: 20%;
            height: 30%;
            background-color: #2aabd2;
        }
        .box5 {
            /*align-self: flex-end;*/
            /*flex-shrink: 0;*/
            /*flex-grow: 1;*/
            width: 10%;
            height: 20%;
            background-color: #32c086;
        }
        .box6 {
            width: 50%;
            height: 40%;
            background-color: #5fc0cd;
        }
    </style>

完成代码:

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <title>flex编码实战</title>
    <style>
        body {
            display: flex;
            /*flex-direction: column;*/
            /*flex-wrap: wrap;*/
            /*flex-wrap: wrap-reverse;*/
            /*justify-content: flex-start;*/
            /*justify-content: flex-end;*/
            /*justify-content: center;*/
            /*justify-content: space-between;*/
            /*justify-content: space-around;*/
            /*align-items: center;*/
            /*align-items: flex-start;*/
            /*align-items: flex-end;*/
            /*align-items: baseline;*/
            /*align-content: center;*/
            /*align-content: space-between;*/
            /*align-content: space-around;*/
            /*align-content: stretch;*/
            width: 80vw;
            height: 80vh;
            margin: 2rem auto;
            border: 1px solid #000;
        }
        .box1 {
            display: flex;
            justify-content: center;
            align-items: center;
            /*order: 5;*/
            flex-shrink: 0;
            width:30%;
            height:30%;
            border: 1px solid #ff0000;
        }
        .box2 {
            width:60%;
            height: 60%;
            background-color: #ffff00;
        }
        .box3 {
            width: 30%;
            height:30%;
            background-color: #d58512;
        }
        .box4 {
            width: 20%;
            height: 30%;
            background-color: #2aabd2;
        }
        .box5 {
            /*align-self: flex-end;*/
            /*flex-shrink: 0;*/
            /*flex-grow: 1;*/
            width: 10%;
            height: 20%;
            background-color: #32c086;
        }
        .box6 {
            width: 50%;
            height: 40%;
            background-color: #5fc0cd;
        }
    </style>
</head>
<body>
<div class="box1">1
    <div class="box2">2</div>
</div>
<div class="box3">3</div>
<div class="box4">4</div>
<div class="box5">5</div>
<div class="box6">6</div>
</body>
</html>
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值