HTML CSS examples for CSS Widget:Grid
Centering grid items in an auto-fill container
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <style id="compiled-css" type="text/css"> .wrap {<!--from www . j av a2s . c o m--> display:flex; flex-direction:column; } .grid { display:grid; grid-template-columns:repeat(auto-fit, minmax(100px, 2fr)); grid-gap:2rem; border:2px solid Chartreuse; justify-items:center; } .item { background:yellow; border:2px solid blue; } </style> </head> <body> <div class="wrap"> <div class="grid"> <div class="item"> Lorem ip </div> <div class="item"> Lorem ip </div> </div> </div> </body> </html>