【CSS 弹性布局】色子案例

【CSS 弹性布局】色子案例_第1张图片

DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Documenttitle>
head>
<style>
    .container {
        width: 600px;
        display: flex;
        justify-content: center;
        border: 1px solid #ccc;
        border-radius: 6px;
    }

    .item {
        width: 60px;
        height: 60px;
        border: 1px solid #ccc;
        border-radius: 6px;
        margin: 12px;
        padding: 6px;
        box-sizing: border-box;
    }

    .point {
        width: 13px;
        height: 13px;
        flex-shrink: 0;
        border-radius: 50%;
        background-color: blue;
    }

    .one {
        display: flex;
        justify-content: center;
        align-items: center;
    }

    .one>.point {
        background-color: red;
    }

    .two {
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        align-items: center;
    }

    .three {
        display: flex;
        justify-content: space-between;
    }

    .three .point:nth-child(1) {
        align-self: flex-end;

    }

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

    .three .point:nth-child(3) {
        align-self: flex-start;
    }

    .four {
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    .four div {
        height: 100%;
        display: flex;
        flex-direction: column;
        justify-content: space-between;
    }
    .four .point {
        background-color: red;
    }

    .five {
        display: flex;
        justify-content: center;
        align-items: center;
    }

    .five div {
        height: 100%;
        display: flex;
        flex-direction: column;
        justify-content: space-between;
    }

    .six {
        display: flex;
        justify-content: space-around;
        align-items: center;
    }
    .six div {
        height: 100%;
        display: flex;
        flex-direction: column;
        justify-content: space-between;
    }
style>

<body>
    <div class="container">
        <div class="item one">
            <span class="point">span>
        div>
        <div class="item two">
            <span class="point">span>
            <span class="point">span>
        div>
        <div class="item three">
            <span class="point">span>
            <span class="point">span>
            <span class="point">span>
        div>
        <div class="item four">
            <div>
                <span class="point">span>
                <span class="point">span>
            div>
            <div>
                <span class="point">span>
                <span class="point">span>
            div>
        div>
        <div class="item five">
            <div>
                <span class="point">span>
                <span class="point">span>
            div>
            <span class="point">span>
            <div>
                <span class="point">span>
                <span class="point">span>
            div>
        div>
        <div class="item six">
            <div>
                <span class="point">span>
                <span class="point">span>
                <span class="point">span>
            div>
            <div>
                <span class="point">span>
                <span class="point">span>
                <span class="point">span>
            div>
        div>
    div>
body>

html>

你可能感兴趣的:(css笔记,弹性布局,CSS)