131 lines
2.9 KiB
Plaintext
131 lines
2.9 KiB
Plaintext
<!-- 只替换 <style> 部分,其他保持不变 -->
|
|
<style>
|
|
/* ...(前面的样式如 .category-page, .search-bar 等保持不变)... */
|
|
|
|
/* 分类内容区 —— 关键修复 */
|
|
.category-content {
|
|
display: flex;
|
|
margin-top: 60px;
|
|
padding: 0 16px;
|
|
max-width: 1400px;
|
|
margin: 60px auto 0 auto; /* 更安全的居中 */
|
|
width: 100%;
|
|
gap: 20px;
|
|
min-height: calc(100vh - 60px); /* 避免内容太短时布局塌陷 */
|
|
}
|
|
|
|
/* 左侧一级分类 */
|
|
.primary-category {
|
|
width: 120px;
|
|
background: white;
|
|
border-radius: 12px;
|
|
padding: 12px 0;
|
|
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
|
|
flex-shrink: 0;
|
|
height: fit-content; /* 防止拉伸 */
|
|
max-height: calc(100vh - 80px); /* 避免溢出屏幕 */
|
|
overflow-y: auto;
|
|
}
|
|
|
|
/* 右侧商品区域 —— 必须 flex: 1 才能占满剩余空间 */
|
|
.product-content {
|
|
flex: 1;
|
|
display: flex;
|
|
flex-direction: column;
|
|
min-width: 0; /* 防止 flex 子项溢出 */
|
|
background: #f8fafc; /* 与背景一致,或可设为 white */
|
|
padding: 16px 0;
|
|
border-radius: 12px;
|
|
}
|
|
|
|
/* 商品网格容器需要滚动时也能正常工作 */
|
|
.product-content > * {
|
|
flex-shrink: 0; /* 防止 header/grid 被压缩 */
|
|
}
|
|
|
|
/* ===== 响应式:小屏手机 (小于等于 414px) ===== */
|
|
@media screen and (max-width: 414px) {
|
|
.category-content {
|
|
flex-direction: column;
|
|
padding: 0 12px;
|
|
margin-top: 55px; /* 匹配搜索栏高度 */
|
|
}
|
|
|
|
.primary-category {
|
|
width: 100%;
|
|
display: flex;
|
|
flex-wrap: wrap;
|
|
padding: 8px;
|
|
height: auto;
|
|
max-height: none;
|
|
overflow: visible;
|
|
}
|
|
|
|
.primary-item {
|
|
width: calc(25% - 8px);
|
|
margin: 4px;
|
|
padding: 10px 8px;
|
|
text-align: center;
|
|
}
|
|
|
|
.primary-icon {
|
|
margin-right: 0;
|
|
margin-bottom: 4px;
|
|
font-size: 16px;
|
|
}
|
|
|
|
.primary-name {
|
|
font-size: 12px;
|
|
}
|
|
|
|
.product-grid {
|
|
grid-template-columns: 1fr;
|
|
gap: 16px;
|
|
}
|
|
|
|
.search-container {
|
|
padding: 0 12px;
|
|
height: 55px;
|
|
}
|
|
|
|
.search-box {
|
|
padding: 8px 16px;
|
|
}
|
|
|
|
.category-header {
|
|
padding: 0;
|
|
}
|
|
}
|
|
|
|
/* 中屏及以上保持网格列数变化,但布局仍是左右 */
|
|
@media screen and (min-width: 415px) {
|
|
.product-grid {
|
|
display: grid;
|
|
gap: 20px;
|
|
}
|
|
}
|
|
|
|
@media screen and (min-width: 415px) and (max-width: 768px) {
|
|
.product-grid {
|
|
grid-template-columns: repeat(2, 1fr);
|
|
}
|
|
}
|
|
|
|
@media screen and (min-width: 769px) and (max-width: 1024px) {
|
|
.product-grid {
|
|
grid-template-columns: repeat(3, 1fr);
|
|
}
|
|
}
|
|
|
|
@media screen and (min-width: 1025px) {
|
|
.product-grid {
|
|
grid-template-columns: repeat(4, 1fr);
|
|
}
|
|
}
|
|
|
|
@media screen and (min-width: 1400px) {
|
|
.product-grid {
|
|
grid-template-columns: repeat(5, 1fr);
|
|
}
|
|
}
|
|
</style> |