商品卡片需用响应式单位(rem/%)配合max-width:100%、box-sizing:border-box及aspect-ratio控制尺寸与比例;价格组用flex基线对齐;折扣标绝对定位;按钮增强:active反馈并禁用重复提交;iOS图片放大改用background-position模拟;必设alt属性与焦点可访问性。
直接用 px 写死宽度或 margin 会导致小屏溢出、大屏留白过多。必须用响应式单位组合:移动端优先设 max-width: 100%,配合 padding 用 rem 或 %,外层容器加 box-sizing: border-box 避免内边距撑大尺寸。
aspect-ratio: 4/3(现代浏览器)或伪元素 hack(旧版)控制宽高比,防止拉伸变形line-height: 1.4 而非固定 px,适配缩放和字体大小变化flex 容器里对子项设 width: 100%,容易触发 flex 的最小尺寸限制,改用 flex: 1 更稳妥常见错误是把原价和折后价都设 display: inline-block 然后靠 vertical-align 对齐——一旦字体加载延迟或字号变化,立刻错位。正确做法是用 grid 或 flex 布局明确基线。
.price-group {
display: flex;
align-items: baseline;
gap: 0.5rem;
}
.price-group .original {
text-decoration: line-through;
color: #999;
}
.price-group .current {
font-weight: bold;
font-size: 1.25rem;
}
position: relative,避免影响流式布局margin-top: -Xpx 往上提折扣标,会破坏可访问性(屏幕阅读器顺序错乱)font-variant-numeric: tabular-nums,保证多位数对齐纯 CSS 实现的按钮状态只有 :hover 和 :active,但用户常反馈“点没点上”,尤其在触摸设备上。需要补足视觉反馈链:
:active 必须有明显样式变化(如背景色加深、transform: scale(0.98)),且持续时间不能低于 100mstransition: all 0.2s ease 到按钮本身,避免 :hover 突然跳变cursor: not-allowed 和 pointer-events: none
iOS Safari 对 transform: scale() + overflow: hidden 组合有渲染 bug,常导致放大后内容被裁切或卡顿。绕过方式是不用纯 CSS 放大,改用 background-size: cover + background-position 模拟缩放效果。
.product-image {
background-size: cover;
background-position: center;
transition: background-position 0.3s ease;
}
.product-image:hover {
background-position: center 20%;
}

z-index 分层,且给弹层加 will-change: transform 提升合成层img 标签上直接写 width/height 属性,用 CSS 控制,否则响应式时容易失真alt 属性,即使为空也要写 alt="",否则屏幕阅读器会读出文件名