主页
CSS
CSS 网格容器
试用:使用 justify-content: space-around
运行 ❯
获取您
自己的
网站
×
更改方向
保存代码
更改主题,深色/浅色
前往 Spaces
<!DOCTYPE html> <html> <head> <style> .grid-container { display: grid; justify-content: space-around; grid-template-columns: 50px 50px 50px; /*Make the grid smaller than the container*/ gap: 10px; background-color: #2196F3; padding: 10px; } .grid-container > div { background-color: rgba(255, 255, 255, 0.8); text-align: center; padding: 20px 0; font-size: 30px; } </style> </head> <body> <h1>The justify-content Property</h1> <p>Use the <em>justify-content</em> property to align the grid inside the container.</p> <p>The value "space-around" will give the columns equal amount of space around them:</p> <div class="grid-container"> <div>1</div> <div>2</div> <div>3</div> <div>4</div> <div>5</div> <div>6</div> </div> </body> </html>