弹性布局理解及应用---骰子小案例

今天要给大家分享的是css3中非常重要的一个知识点-----弹性布局!!!

有多重要了,在PC端可能还看不出来有多好用,但是在移动端这个弹性布局会非常非常的好用大笑

偷笑偷笑偷笑在给大家分享这个应用小案例之前,先把弹性布局的知识点给梳理一下:



7、案例:骰子的实现

<!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>
        body {
            background-color: tomato;
        }

        ul {
            list-style: none;
            margin: 20px;
            padding: 0;
            background-color: #fff;
            border: 1px solid #000;
            border-radius: 20px;
            width: 150px;
            height: 150px;

            padding: 10px;
            box-sizing: border-box;

            float:left;
            display: flex;
        }

        li {
            width: 20px;
            height: 20px;
            background-color: #000;
            border-radius: 50%;
        }

        .ul1 {
            justify-content: center;
            align-items: center;
        }

        .ul2 {
            justify-content: space-around;
            align-items: center;
        }

        .ul3 {
            justify-content: space-around;
            padding: 20px;
        }

        .ul3 li:nth-child(2) {
            align-self: center;
        }

        .ul3 li:nth-child(3) {
            align-self: flex-end;
        }

        /* 第四个面 */
        .ul4 {
            flex-wrap: wrap;
            justify-content: space-around;
            align-items: center;
        }

        .ul4 li {
            margin: 0px 20px;
        }

        /* 第五个面 */
        .ul5 {
            flex-wrap: wrap;
            justify-content: space-around;
            align-items: center;
        }

        .ul5 li{
            margin: 0px 20px;
        }

        .ul5 li:nth-child(3) {
            margin: 0px 50px;
        }

        /* 第六个面*/
        .ul6 {
            flex-wrap: wrap;
            justify-content: space-around;
            align-items: center;
        }

        .ul6 li{
            margin: 0px 20px;
        }
    </style>
</head>
<body>
    <h3>骰子的第1个面</h3>
    <ul class="ul1">
        <li></li>
    </ul>
    <h3>骰子的第2个面</h3>
    <ul class="ul2">
        <li></li>
        <li></li>
    </ul>
    <h3>骰子的第3个面</h3>
    <ul class="ul3">
        <li></li>
        <li></li>
        <li></li>
    </ul>
    <h3>骰子的第4个面</h3>
    <ul class="ul4">
        <li></li>
        <li></li>
        <li></li>
        <li></li>
    </ul>
    <h3>骰子的第5个面</h3>
    <ul class="ul5">
        <li></li>
        <li></li>
        <li></li>
        <li></li>
        <li></li>
    </ul>
    <h3>骰子的第6个面</h3>
    <ul class="ul6">
        <li></li>
        <li></li>
        <li></li>
        <li></li>
        <li></li>
        <li></li>
    </ul>
</body>
</html>

10、弹性布局总结:


  • 3
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值