CSS Grid布局-项目对齐

CSS Grid布局CSS display: grid1 个文件更新于 2026-04-06
html公开前 25 行,完整代码需登录
<style>
  .grid {
    display: grid;
    grid-template-columns: repeat(3, 150px);
    grid-template-rows: repeat(3, 150px);
    gap: 10px;
    background-color: #e8e8e8;
    padding: 10px;
    justify-content: center;
    align-content: center;
    min-height: 500px;
  }
  .grid-item {
    background-color: #2196F3;
    border: 1px solid #000;
    color: white;
    font-size: 20px;
    font-weight: bold;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .grid-item:nth-child(1) {
    justify-self: start;

登录后可以查看完整源码、在线编辑并实时预览运行效果。