feat: 调整RecommendPostsList组件样式

This commit is contained in:
duanshuwen
2025-10-14 19:44:18 +08:00
parent 851bfe149c
commit 4b14ea4f08
8 changed files with 79 additions and 51 deletions

View File

@@ -1,17 +1,28 @@
<template> <template>
<view class="container"> <view class="container">
<ModuleTitle :title="recommendTheme.themeName" /> <ModuleTitle :title="recommendTheme.themeName" />
<view class="container-scroll">
<view class="container-scroll font-size-0">
<view <view
class="card-item bg-white inline-block rounded-20 mr-8"
v-for="(item, index) in recommendTheme.recommendPostsList" v-for="(item, index) in recommendTheme.recommendPostsList"
:key="index" :key="index"
@click="sendReply(item)"
> >
<view class="mk-card-item" @click="sendReply(item)"> <view class="m-4 relative">
<image class="card-img" :src="item.coverPhoto" mode="aspectFill" /> <image
class="card-img rounded-16 relative z-10"
:src="item.coverPhoto"
mode="aspectFill"
/>
<view class="overlay-gradient"> <view class="shadow absolute rounded-16"></view>
<text class="overlay-text">{{ item.topic }}</text>
</view> </view>
<view
class="card-text color-171717 font-size-14 line-height-20 border-box"
>
{{ item.topic }}
</view> </view>
</view> </view>
</view> </view>

View File

@@ -1,7 +1,3 @@
.container {
width: 100%;
}
.container-scroll { .container-scroll {
display: flex; display: flex;
flex-direction: row; flex-direction: row;
@@ -9,45 +5,26 @@
margin: 4px 0 6px; margin: 4px 0 6px;
} }
.mk-card-item { .card-item {
flex-shrink: 0; /* 关键:防止 flex 布局压缩子元素宽度 */ width: 128px;
width: 142px; height: 164px;
height: 126px; }
border-radius: 10px;
overflow: hidden;
margin-right: 8px;
position: relative;
.card-img { .card-img {
width: 100%; height: 120px;
height: 100%; width: 120px;
display: block;
} }
/* 渐变背景层 */ .shadow {
.overlay-gradient { background-color: #e5e8ee;
position: absolute; height: 96px;
bottom: 0; width: 96px;
left: 0; bottom: -4px;
width: 100%; left: 50%;
height: 50px; /* 渐变层高度,可调 */ transform: translateX(-50%);
background: linear-gradient( z-index: 1;
to bottom,
rgba(0, 0, 0, 0.001) 0%,
rgba(0, 0, 0, 0.5) 100%
);
display: flex;
align-items: flex-end; /* 文字贴近底部 */
padding: 0 8px 6px; /* 内边距让文字与边缘保持距离 */
box-sizing: border-box;
} }
/* 渐变层上的文字 */ .card-text {
.overlay-text { padding: 4px 8px 8px;
color: #fff;
font-weight: 500;
font-size: $uni-font-size-sm;
text-align: left;
width: 100%;
}
} }

View File

@@ -1,4 +1,8 @@
// 字体-size // 字体-size
.font-size-0 {
font-size: 0px;
}
.font-size-12 { .font-size-12 {
font-size: 12px; font-size: 12px;
} }

View File

@@ -17,3 +17,4 @@
@import "./scroll.scss"; @import "./scroll.scss";
@import "./overflow.scss"; @import "./overflow.scss";
@import "./width.scss"; @import "./width.scss";
@import "./z-index.scss";

View File

@@ -1,4 +1,12 @@
// 外边距-bottom // 外边距-bottom
.m-4 {
margin: 4px;
}
.mr-8 {
margin-right: 8px;
}
.mb-10 { .mb-10 {
margin-bottom: 10px; margin-bottom: 10px;
} }

View File

@@ -1,4 +1,8 @@
// 内边距 // 内边距
.p-8 {
padding: 8px;
}
.p-12 { .p-12 {
padding: 12px; padding: 12px;
} }

View File

@@ -11,6 +11,14 @@
border-radius: 12px; border-radius: 12px;
} }
.rounded-16 {
border-radius: 16px;
}
.rounded-20 {
border-radius: 20px;
}
.rounded-full { .rounded-full {
border-radius: 50%; border-radius: 50%;
} }

View File

@@ -0,0 +1,15 @@
.z-0 {
z-index: 0;
}
.z-10 {
z-index: 10;
}
.z-20 {
z-index: 20;
}
.z-30 {
z-index: 30;
}