目标:看到 ai-home 的画布、侧栏、对话框、viewer 容器时,能判断布局问题大概率出在 flex、position、overflow 还是 z-index。
content 内容 padding 内边距 border 边框 margin 外边距
排查尺寸不对时,先在 DevTools 的 Computed 面板看盒模型,而不是直接猜 CSS。
AIHom 里左画布、右对话、工具栏、按钮组,经常是 flex。
.page {
display: flex;
}
.canvas {
flex: 1;
}
.chat {
width: 360px;
}
| 属性 | 读法 |
|---|---|
display: flex | 子元素排成一行或一列 |
flex: 1 | 吃掉剩余空间 |
gap | 子元素之间的间距 |
| 现象 | 优先查 |
|---|---|
| 弹窗被盖住 | z-index 和父级 stacking context |
| 内容被裁掉 | overflow: hidden |
| 浮层位置不对 | position: absolute/fixed 的参考对象 |
| 移动端挤爆 | 固定宽度、最小宽度、flex 收缩 |
前端功能问题先看数据流;纯视觉问题先看盒模型和布局。不要一上来改一堆样式,先在 DevTools 临时开关 CSS,确认是哪一条规则影响了结果。