<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Wrapping of Flex Items inside Flex Container</title> <style> .flex-container { width: 500px; min-height: 320px; margin: 0 auto; font-size: 32px; border: 5px solid black; /* Safari */ display: -webkit-flex; -webkit-flex-wrap: wrap; /* Standard syntax */ display: flex; flex-wrap: wrap; } .flex-container div{ padding: 10px; width: 130px; } .item1 { background: yellow; } .item2 { background: blue; } .item3 { background: purple; } .item4 { background: orange; } </style> </head> <body> <div class="flex-container"> <div class="item1">1</div> <div class="item2">2</div> <div class="item3">3</div> <div class="item4">4</div> </div> <p><strong>Note:</strong> The other values for the align-items property like, "flex-start", "flex-end", "baseline" and "stretch" to understand how it aligns the items inside flex container.</p> </body> </html>