bw-mini-app/src/components/TemplateCard/index.css

222 lines
4.2 KiB
CSS

.template-card {
background: #fff;
border-radius: 20px;
padding: 0;
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
transition: all 0.3s ease;
cursor: pointer;
display: flex;
flex-direction: column;
position: relative;
overflow: hidden;
margin-bottom: 16px;
break-inside: avoid;
width: 100%;
box-sizing: border-box;
}
.template-card:active {
transform: translateY(-2px);
box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
}
/* 合成对比图片区域 */
.image-comparison {
position: relative;
padding: 16px;
background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
}
.merged-image-container {
position: relative;
border-radius: 12px;
overflow: hidden;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
height: 180px;
display: flex;
}
.image-half {
position: relative;
overflow: hidden;
transition: width 0.1s ease-out;
}
.comparison-image {
width: 200%; /* 图片宽度设为容器的2倍 */
height: 100%;
object-fit: cover;
display: block;
background: #f5f5f5;
transition: opacity 0.3s ease;
}
/* 左半部分显示原图的左半部分 */
.left-image {
transform: translateX(0); /* 不偏移,显示图片左半部分 */
}
/* 右半部分显示效果图的右半部分 */
.right-image {
transform: translateX(-50%); /* 向左偏移50%,显示图片右半部分 */
}
.comparison-image:not([src]) {
opacity: 0.5;
}
/* 标签容器 */
.image-labels {
position: absolute;
bottom: 0;
left: 0;
right: 0;
display: flex;
z-index: 2;
}
.label-left,
.label-right {
display: flex;
justify-content: center;
align-items: center;
padding: 8px 4px;
backdrop-filter: blur(10px);
-webkit-backdrop-filter: blur(10px);
transition: width 0.1s ease-out;
min-width: 40px; /* 确保标签有最小宽度 */
}
.label-left {
background: rgba(52, 152, 219, 0.9);
border-radius: 0 0 0 12px;
}
.label-right {
background: rgba(46, 204, 113, 0.9);
border-radius: 0 0 12px 0;
}
.label-text {
color: #fff;
font-size: 12px;
font-weight: 600;
text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}
/* 可拖拽分割线 */
.split-line {
position: absolute;
top: 0;
bottom: 0;
width: 4px; /* 增加宽度便于拖拽 */
background: linear-gradient(to bottom,
rgba(255, 255, 255, 0.8) 0%,
rgba(255, 255, 255, 0.9) 50%,
rgba(255, 255, 255, 0.8) 100%);
transform: translateX(-50%);
z-index: 3;
cursor: col-resize;
touch-action: none; /* 防止页面滚动 */
transition: left 0.1s ease-out;
}
.split-handle {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 32px;
height: 32px;
background: rgba(255, 255, 255, 0.95);
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
box-shadow: 0 2px 12px rgba(0, 0, 0, 0.25);
border: 2px solid rgba(0, 122, 255, 0.4);
cursor: col-resize;
touch-action: none;
transition: all 0.2s ease;
}
.split-handle:active {
transform: translate(-50%, -50%) scale(1.1);
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}
.split-icon {
font-size: 12px;
color: #007AFF;
font-weight: bold;
}
/* 模板信息区域 */
.template-info {
padding: 16px 20px 20px;
display: flex;
flex-direction: column;
gap: 8px;
}
.template-name {
font-size: 18px;
font-weight: 700;
color: #1a1a1a;
line-height: 1.3;
margin-bottom: 4px;
display: block;
}
.template-desc {
font-size: 14px;
color: #666;
line-height: 1.5;
margin-bottom: 12px;
display: block;
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
}
.template-meta {
display: flex;
justify-content: space-between;
align-items: flex-end;
margin-top: auto;
}
.tags-container {
display: flex;
flex-wrap: wrap;
gap: 6px;
flex: 1;
}
.template-tag {
font-size: 11px;
font-weight: 500;
padding: 4px 10px;
border-radius: 14px;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: #fff;
display: inline-block;
white-space: nowrap;
text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}
.credit-cost {
margin-left: 12px;
}
.cost-text {
font-size: 12px;
color: #FF6B35;
font-weight: 600;
background: rgba(255, 107, 53, 0.1);
padding: 4px 8px;
border-radius: 12px;
border: 1px solid rgba(255, 107, 53, 0.2);
}