JSFiddle - React, Tailwind, and code Playground
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Multi-column Layout</title>
</head>
<body>
<style>
body {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
}
.columns {
column-width: 240px;
column-gap: 10px;
width: 100%; /* Ensure the container spans full width */
max-width: 1000px; /* Set a max-width for better control */
box-sizing: border-box;
padding: 10px;
}
.column-item {
background-color: lightblue;
border: 1px solid #ccc;
padding: 20px;
margin-bottom: 10px;
display: inline-block; /* Ensures items are treated as block-level elements within columns */
width: 100%;
box-sizing: border-box;
}
</style>
<div class="columns">
<div class="column-item">1<br/>and next<br/>and next<br/>and next<br/>and next<br/>and next</div>
<div class="column-item">2</div>
<div class="column-item">3</div>
<div class="column-item">4</div>
<div class="column-item">5</div>
<div class="column-item">6</div>
<div class="column-item">7</div>
<div class="column-item">8</div>
<div class="column-item">9</div>
</div>
</body>
</html>