diff --git a/src/components/TemplateCard/index.css b/src/components/TemplateCard/index.css index 40ba7a0..95dd6ff 100644 --- a/src/components/TemplateCard/index.css +++ b/src/components/TemplateCard/index.css @@ -9,7 +9,6 @@ flex-direction: column; position: relative; overflow: hidden; - margin-bottom: 16px; break-inside: avoid; width: 100%; box-sizing: border-box; @@ -32,7 +31,8 @@ border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1); - height: 180px; + min-height: 180px; + max-height: 300px; /* 设置最大高度避免过高 */ display: flex; } @@ -43,6 +43,22 @@ background-color: #f5f5f5; } +.image-wrapper { + position: relative; + width: 100%; + height: 100%; + display: flex; + align-items: center; + justify-content: center; +} + +.comparison-image { + width: 100%; + height: auto; /* 高度自适应,保持宽高比 */ + max-height: 100%; + display: block; +} + /* 标签容器 */ .image-labels { position: absolute; @@ -156,6 +172,7 @@ text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; + line-clamp: 2; -webkit-box-orient: vertical; } diff --git a/src/components/TemplateCard/index.tsx b/src/components/TemplateCard/index.tsx index 81a61d9..d217961 100644 --- a/src/components/TemplateCard/index.tsx +++ b/src/components/TemplateCard/index.tsx @@ -1,4 +1,4 @@ -import { View, Text } from '@tarojs/components' +import { View, Text, Image } from '@tarojs/components' import { useState, useRef } from 'react' import Taro from '@tarojs/taro' import { Template } from '../../store/types' @@ -73,30 +73,34 @@ export default function TemplateCard({ template, onClick }: TemplateCardProps) { onTouchMove={handleTouchMove} onTouchEnd={handleTouchEnd} > - {/* 左半部分 - 原图的左半部分 */} + {/* 左半部分 - 原图 */} + + + - {/* 右半部分 - 效果图的右半部分 */} + {/* 右半部分 - 效果图 */} + + + {/* 可拖拽的分割线 */} diff --git a/src/pages/home/index.css b/src/pages/home/index.css index 616c1d0..792ea68 100644 --- a/src/pages/home/index.css +++ b/src/pages/home/index.css @@ -29,27 +29,14 @@ font-weight: 500; } -/* 瀑布流布局 - 使用flex布局兼容小程序 */ +/* 瀑布流布局 - 简化为标准grid布局 */ .template-grid { - display: flex; - flex-direction: column; - flex-wrap: wrap; - max-height: 2000px; /* 设置一个最大高度来实现换列效果 */ + display: grid; + grid-template-columns: 1fr 1fr; gap: 12px; max-width: 100%; margin: 0 auto; - align-content: flex-start; -} - -/* 如果支持grid布局,使用grid */ -@supports (display: grid) { - .template-grid { - display: grid; - grid-template-columns: 1fr 1fr; - grid-gap: 12px; - max-height: none; - flex-wrap: nowrap; - } + padding: 0 4px; } /* 响应式调整 */ @@ -61,15 +48,13 @@ .template-grid { max-width: 600px; gap: 16px; - grid-gap: 16px; + padding: 0; } } @media (min-width: 1024px) { - @supports (display: grid) { - .template-grid { - grid-template-columns: 1fr 1fr 1fr; - max-width: 900px; - } + .template-grid { + grid-template-columns: 1fr 1fr 1fr; + max-width: 900px; } } \ No newline at end of file