Home
CSS
CSS Grid Container
Tryit: Using place-content: center center
Run ❯
Get your
own
website
Result Size:
625 x 534
×
Change Orientation
Save Code
Change Theme, Dark/Light
Go to Spaces
<!DOCTYPE html> <html> <head> <style> .grid-container { display: grid; height: 400px; grid-template-columns: 70px 70px 70px; gap: 10px; background-color: dodgerblue; padding: 10px; place-content: end space-between; } .grid-container > div { background-color: #f1f1f1; color:#000; padding: 10px; font-size: 30px; text-align: center; } </style> </head> <body> <h1>The place-content Property</h1> <p>Use the <em>place-content</em> property to both vertically and horizontaly align the grid inside the container.</p> <p>The "end space-between" value aligns the grid lines towards the bottom of the grid container, and aligns the grid items with the same space between them horizontally:</p> <div class="grid-container"> <div>1</div> <div>2</div> <div>3</div> <div>4</div> <div>5</div> <div>6</div> <div>7</div> <div>8</div> </div> </body> </html>