CSS Grid table layout example

Date: 2024-04-29

Source: https://stackoverflow.com/a/63018503/1052129

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>CSS Grid table layout example</title>
    <link rel="style" src="index.css" type="css" />
    <style>
        .parent {
            display: grid;
            grid-template-columns: repeat(3, 1fr);
        }

        .row {
            display: grid;
            grid-column: 1 / -1;
            grid-template-columns: subgrid;
        }

        .col {
            border: 1px #000 solid;
        }
    </style>
</head>

<body>
    <h1>CSS Grid table layout example</h1>

    <div class="parent">
        <div class="row">
            <div class="col">1A</div>
            <div class="col">1B</div>
            <div class="col">1C</div>
        </div>
        <div class="row">
            <div class="col">2A</div>
            <div class="col">2B<br />ABCDEDFSJISDOFUDIOSFUIODSUFIOUDOSIFUIODSUFIOUIODSF</div>
            <div class="col">2C</div>
        </div>
        <div class="row">
            <div class="col">3A</div>
            <div class="col">3B</div>
            <div class="col">3C</div>
        </div>
    </div>

</body>

</html>

84930cookie-checkCSS Grid table layout example