.popup-root { width: 0; // 解决 H5 关闭抽屉存在黑色背景 BUG } .drawer-wrapper { background-color: rgba(0, 0, 0, 0.4); width: 100vw; height: 100vh; height: 100dvh; /* 使用动态视口高度,排除浏览器 UI */ position: fixed; left: 0; top: 0; display: flex; &.direction-left { flex-direction: row; justify-content: flex-end; } &.direction-bottom { flex-direction: column; justify-content: flex-start; } } .drawer-content { display: flex; flex-direction: column; background: #fff; transition: all 0.2s ease; will-change: transform; &.direction-left { position: absolute; left: 0; box-shadow: 4rpx 0 20rpx rgba(0, 0, 0, 0.2); border-radius: 0 30rpx 30rpx 0; transform: translateX(-100%); } &.direction-bottom { position: absolute; bottom: 0; left: 0; border-radius: 20rpx 20rpx 0 0; box-shadow: 0 -4rpx 20rpx rgba(0, 0, 0, 0.2); transform: translateY(100%); max-height: 100vh; max-height: 100dvh; /* 限制最大高度,确保不超出视口 */ overflow: hidden; // 自适应高度模式的额外样式 &.auto-height { overflow: visible; } } .head-box { box-sizing: border-box; width: 100%; position: sticky; top: 0; z-index: 10; background: #fff; display: flex; flex-direction: row; padding: 30rpx 30rpx 20rpx; align-items: center; justify-content: flex-end; flex-shrink: 0; /* 防止被压缩 */ border-radius: 20rpx 20rpx 0 0; /* 与父容器保持一致 */ min-height: 94rpx; /* 保证不包含关闭按钮时高度撑开一致 */ border-bottom: 2rpx solid #f0f0f0; /* 调深浅灰色下边框 */ .title { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); max-width: calc(100% - 200rpx); font-weight: 600; color: rgba(21, 23, 31, 1); padding-top: 10rpx; } .close-btn { z-index: 1; cursor: pointer; padding: 10rpx; /* 增加点击区域 */ margin: -10rpx; /* 抵消padding,保持视觉位置不变 */ .iconfont { font-size: 30rpx; color: #333; } } } .content-box { flex: 1; margin: 20rpx 0; overflow: auto; min-height: 0; } } .drawer-mask { position: absolute; top: 0; left: 0; width: 100vw; height: 100vh; z-index: -1; } .drawer-show { &.direction-left { transform: translateX(0); } &.direction-bottom { transform: translateY(0); } }