Show Output
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Example of Flex Items Alignment along Cross Axis</title> <style> .flex-container { width: 500px; min-height: 300px; margin: 0 auto; font-size: 32px; border: 1px solid #666; /* Safari */ display: -webkit-flex; -webkit-align-items: center; /* Standard syntax */ display: flex; align-items: center; } .flex-container div{ padding: 10px; } .item1 { width: 75px; height: 100px; background: #e84d51; } .item2 { width: 125px; height: 200px; background: #7ed636; } .item3 { width: 175px; height: 150px; background: #2f97ff; } </style> </head> <body> <div class="flex-container"> <div class="item1">1</div> <div class="item2">2</div> <div class="item3">3</div> </div> <p><strong>Note:</strong> Try 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>