Flexbox Example Ten

Example: Modify flex-grow, flex-shrink, and flex-basis

Resize the viewport

Box 1

Box 2

Box 3

Box 4

Box 5

Box 6

Box 7

Box 8

HTML

<div class="container">
    <p class="box">Box 1</p>
    <p class="box">Box 2</p>
    <p class="box2">Box 3</p>
    <p class="box">Box 4</p>
    <p class="box">Box 5</p>
    <p class="box">Box 6</p>
    <p class="box">Box 7</p>
    <p class="box">Box 8</p>
</div>

CSS

.container {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: space-around;
    align-items: flex-start;
    align-content: flex-start;
    background-color: yellow;
    border: thin solid black;
    width: 80%;
    height: 400px;
    align-content: flex-end;
}

.box {
    flex-grow: 0;
    flex-shrink: 0;
    flex-basis: 200px;
    background-color: aliceblue;
    border: thin solid black;
}

.box2 {
    flex-grow: 1;
    flex-shrink: 1;
    flex-basis: 200px;
    background-color: green;
    border: thin solid black;
}