主页

腾讯会议图片_20220711173725.png

一点

css

.root {
    width: 300px;
    height: 300px;
    border-radius: 16px;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 1px 2px 8px rgb(0 0 0 / 10%);
}

.p {
    background-color: red;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    box-shadow: 2px 2px 3px rgb(0 0 0 / 20%) inset;
}

html

<div class="root">
    <div class="p"></div>
</div>

二点

css

.root {
    width: 300px;
    height: 300px;
    border-radius: 16px;
    box-shadow: 1px 2px 8px rgb(0 0 0 / 0.1);
    display: flex;
    margin-top:100px;
    justify-content: space-between;
    padding: 12px;
    box-sizing: border-box;
}

.p {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    box-shadow: 2px 2px 3px rgb(0 0 0 / 20%) inset;
    background-color: red;
}


.p:nth-child(2) {
    align-self: flex-end;
}

html

<div class="root">
    <div class="p"></div>
    <div class="p"></div>
</div>

三点

css

.root {
    width: 300px;
    height: 300px;
    border-radius: 16px;
    box-shadow: 1px 2px 8px rgb(0 0 0 / 0.1);
    display: flex;
    margin-top:100px;
    justify-content: space-between;
    padding: 12px;
    box-sizing: border-box;
}

.p {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    box-shadow: 2px 2px 3px rgb(0 0 0 / 20%) inset;
    background-color: red;
}


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

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

html

<div class="root">
    <div class="p"></div>
    <div class="p"></div>
    <div class="p"></div>
</div>

四点

从4点开始要有分组的思想!且上下排列

css

.root {
    width: 300px;
    height: 300px;
    border-radius: 16px;
    box-shadow: 1px 2px 8px rgb(0 0 0 / 0.1);
    display: flex;
    margin-top:100px;
    padding: 12px;
    box-sizing: border-box;
    flex-direction: column;
    /* justify-content 是设置主轴 */
    /* 主轴 是垂直方向 */
    justify-content: space-between; 
}

.p {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    box-shadow: 2px 2px 3px rgb(0 0 0 / 20%) inset;
    background-color: red;
}

.row {
    display: flex;
    /* justify-content 是设置主轴 */
    /* 主轴 是水平方向 */
    justify-content: space-between;
}

html

<div class="root">
    <div class="row">
        <div class="p"></div>
        <div class="p"></div>
    </div>
    <div class="row">
        <div class="p"></div>
        <div class="p"></div>
    </div>
</div>

五点

css

.root {
    width: 300px;
    height: 300px;
    border-radius: 16px;
    box-shadow: 1px 2px 8px rgb(0 0 0 / 0.1);
    display: flex;
    margin-top: 100px;
    padding: 12px;
    box-sizing: border-box;
    flex-direction: column;
    justify-content: space-between;
}
.p {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    box-shadow: 2px 2px 3px rgb(0 0 0 / 20%) inset;
    background-color: red;
}
.row {
    display: flex;
    justify-content: space-between;
}
.row:nth-child(2) {
    justify-content: center;
}

html

<div class="root">
    <div class="row">
        <div class="p"></div>
        <div class="p"></div>
    </div>
    <div class="row">
        <div class="p"></div>
    </div>
    <div class="row">
        <div class="p"></div>
        <div class="p"></div>
    </div>
</div>

六点

css

.root {
    width: 300px;
    height: 300px;
    border-radius: 16px;
    box-shadow: 1px 2px 8px rgb(0 0 0 / 0.1);
    display: flex;
    margin-top: 100px;
    padding: 12px;
    box-sizing: border-box;
    flex-direction: column;
    justify-content: space-between;
}
.p {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    box-shadow: 2px 2px 3px rgb(0 0 0 / 20%) inset;
    background-color: red;
}
.row {
    display: flex;
    justify-content: space-between;
}

html

<div class="root">
    <div class="row">
        <div class="p"></div>
        <div class="p"></div>
    </div>
    <div class="row">
        <div class="p"></div>
        <div class="p"></div>
    </div>
    <div class="row">
        <div class="p"></div>
        <div class="p"></div>
    </div>
</div>

版权属于:染念
作品采用:本作品采用 知识共享署名-相同方式共享 4.0 国际许可协议 进行许可。
4

目录

来自 《拿骰子来练习flex布局》
评论

染念

博主很懒,啥都没有
159 文章数
565 评论量
4 分类数
163 页面数
已在风雨中度过 5年296天23小时50分
© 2022 染念的笔记—三水没水
浙ICP备19020194号-1