列出容器与项目的关键属性,并实现水平垂直居中。
容器:display:flex;flex-direction(主轴方向);justify-content(主轴对齐);align-items(交叉轴对齐);flex-wrap(换行);gap(间距)。
项目:flex: grow shrink basis;align-self;order。
水平垂直居中:
.parent { display:flex; justify-content:center; align-items:center; }
或 margin:auto 在 flex 子项上也生效。Grid 方案:place-items:center。
题目与答案就在本页;收藏、批注和错题重练在应用内