style.css
setup.css
index.html
section { display: flex; flex-wrap: wrap; height: 120px; } div { width: 120px; } /* So they wrap. */ section:nth-child(1) { align-content: stretch; /* Default. */ } section:nth-child(2) { align-content: start; } section:nth-child(3) { align-content: center; } section:nth-child(4) { align-content: end; } section:nth-child(5) { align-content: space-between; } section:nth-child(6) { align-content: space-around; } section:nth-child(7) { align-content: space-evenly; }
body { font-family: sans-serif; padding: 20px; } div { background-color: tomato; border-bottom: 2px solid firebrick; border-right: 2px solid firebrick; padding: 5px; } section { background-color: gold; } section:not(:first-child) { margin-top: 20px; }
<!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <link href="/assets/styles/reset.css" rel="stylesheet"> <link href="setup.css" rel="stylesheet"> <link href="style.css" rel="stylesheet"> </head> <body> <section> <div> <p>Item 1</p> </div> <div> <p>Item 2 <br>with line <br>breaks</p> </div> <div> <p>Item 3 <br>also</p> </div> <div> <p>Item 4</p> </div> <div> <p>Item 5</p> </div> </section> <section> <div> <p>Item 1</p> </div> <div> <p>Item 2 <br>with line <br>breaks</p> </div> <div> <p>Item 3 <br>also</p> </div> <div> <p>Item 4</p> </div> <div> <p>Item 5</p> </div> </section> <section> <div> <p>Item 1</p> </div> <div> <p>Item 2 <br>with line <br>breaks</p> </div> <div> <p>Item 3 <br>also</p> </div> <div> <p>Item 4</p> </div> <div> <p>Item 5</p> </div> </section> <section> <div> <p>Item 1</p> </div> <div> <p>Item 2 <br>with line <br>breaks</p> </div> <div> <p>Item 3 <br>also</p> </div> <div> <p>Item 4</p> </div> <div> <p>Item 5</p> </div> </section> <section> <div> <p>Item 1</p> </div> <div> <p>Item 2 <br>with line <br>breaks</p> </div> <div> <p>Item 3 <br>also</p> </div> <div> <p>Item 4</p> </div> <div> <p>Item 5</p> </div> </section> <section> <div> <p>Item 1</p> </div> <div> <p>Item 2 <br>with line <br>breaks</p> </div> <div> <p>Item 3 <br>also</p> </div> <div> <p>Item 4</p> </div> <div> <p>Item 5</p> </div> </section> <section> <div> <p>Item 1</p> </div> <div> <p>Item 2 <br>with line <br>breaks</p> </div> <div> <p>Item 3 <br>also</p> </div> <div> <p>Item 4</p> </div> <div> <p>Item 5</p> </div> </section> </body> </html>