flex 实现一个 三点 的色子

flex常用语法

容器常用设置

  • flex-direction 主轴的方向(横向纵向)
  • justify-content 主轴对其方式(从开始对齐,从结束对齐,居中对齐,两端对齐)
  • align-items 交叉轴对齐方式(从开始对齐,从结束对齐,居中对齐,两端对齐)
  • flex-wrap 是否换行

子元素

  • align-self 子元素在交叉轴的对齐方式

在这里插入图片描述

<!DOCTYPE html>
<html>
<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>flex 画骰子</title>
    <style type="text/css">
        .box {
    
    
            width: 200px;
            height: 200px;
            border: 2px solid #ccc;
            border-radius: 10px;
            padding: 20px;

            display: flex;
            justify-content: space-between;
        }
        .item {
    
    
            display: block;
            width: 40px;
            height: 40px;
            border-radius: 50%;
            background-color: #666;
        }
        .item:nth-child(2) {
    
    
            align-self: center;
        }
        .item:nth-child(3) {
    
    
            align-self: flex-end;
        }

    </style>
</head>
<body>
    <div class="box">
        <span class="item"></span>
        <span class="item"></span>
        <span class="item"></span>
    </div>
</body>
</html>```

おすすめ

転載: blog.csdn.net/qq_52151772/article/details/121901639