Flex Boxes

Basisstappen om Flexbox te gebruiken

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

.item {
    width: 100px;
    height: 100px;
    background-color: lightblue;
    margin: 10px;
}

flex-basis

Stel, je wilt dat een container de hele breedte van de pagina in beslag neemt dan pas je het item aan

.container {
    display: flex;
}

.item {
    flex-basis: 100%;
}

More on: https://css-tricks.com/snippets/css/a-guide-to-flexbox/

Basis structuur

image.png

<html>
<head>
    <style>

        .container {
            display: flex;
            flex-direction: column;
            height: 98vh;
        }

        .header {
            background-color: salmon;
            flex: 0 0 100px;
            text-align: center;
            padding: 20px;
        }

        .content {
            display: flex;
            flex: 1;
        }

        .menu {
            background-color: lightblue;
            flex: 1;
            padding: 20px;
            text-align: center;
            margin: 10 10 10 0;
        }

        .main {
            background-color: lightgreen;
            flex: 4;
            padding: 20px;
            text-align: center;
            margin: 10 0 10 0;
        }

        .footer {
            background-color: lightgray;
            flex: 0 0 100px;
            text-align: center;
            padding: 20px;
        }
    </style>
</head>
<body>
    <div class="container">
        <div class="header">Header</div>
        <div class="content">
            <div class="menu">Menu</div>
            <div class="main">Main</div>
        </div>
        <div class="footer">Footer</div>
    </div>
</body>
</html>

flex: 0 0 100px;

xx


Revision #8
Created 6 October 2024 09:44:25 by Max
Updated 6 October 2024 11:11:40 by Max