模板:Index2025/Card2/style.css
来自EaseCation Wiki
更多操作
.card-2-container {
display: flex;
gap: 10px; /* 中间间隔20px */
width: 100%;
box-sizing: border-box;
margin-top: 10px;
height: 200px;
font-size: 16px;
}
.card-2-left {
background-color: rgba(130, 0, 108, 0.1);
backdrop-filter: blur(10px); /* 背景模糊效果 */
flex: 2; /* 自动平分宽度 */
border-radius: 10px; /* 已有的圆角设置 */
padding: 15px;
box-sizing: border-box; /* 确保padding不会增加总宽度 */
border: 1px solid rgba(0, 0, 0, 0.05); /* 淡色描边 */
position: relative;
overflow: hidden; /* 新增:确保内部元素也受圆角约束 */
}
.card-2-right {
background-color: rgba(230, 138, 0, 0.1);
backdrop-filter: blur(10px); /* 背景模糊效果 */
flex: 4; /* 自动平分宽度 */
border-radius: 10px;
padding: 15px;
box-sizing: border-box; /* 确保padding不会增加总宽度 */
border: 1px solid rgba(0, 0, 0, 0.05); /* 淡色描边 */
}
.card-2_title {
font-weight: bold;
margin-bottom: 10px;
font-size: 1.2em;
}
.card-2-text {
font-size: 15px;
}
.card-2-left-image {
float: right;
border-radius: 10px;
transition: transform 0.3s ease;
cursor: pointer;
}
.card-2-text::after {
content: "";
display: table;
clear: both;
}
.card-2-left-image {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 1; /* 图片在底层 */
border-radius: 10px; /* 新增:图片容器也添加圆角 */
overflow: hidden; /* 新增:确保图片本身也显示圆角 */
}
/* 为图片添加从下至上的黑色渐变蒙版 */
.card-2-left-image::after {
content: '';
position: absolute;
bottom: 0;
left: 0;
width: 100%;
height: 100%;
background: linear-gradient(to top, rgba(0, 0, 0, 0.8) 0%, rgba(0, 0, 0, 0) 100%);
pointer-events: none; /* 允许点击穿透到图片 */
}
/* 实际图片样式 */
.card-2-left-image img {
width: 100%;
height: 100%;
object-fit: cover; /* 保持图片比例并覆盖整个容器 */
}
.card-2-left-foreground {
position: absolute;
bottom: 0;
left: 0;
width: 100%;
padding: 15px;
box-sizing: border-box;
z-index: 2; /* 文字在蒙版上方 */
color: white; /* 文字颜色设为白色,与深色蒙版对比 */
}
.card-2-left-texts {
display: flex;
flex-direction: column; /* 垂直排列文字 */
gap: 5px; /* 文字间距 */
}
.card-2-left-foreground-subtitle {
order: 1; /* 排在前面 */
margin: 0;
font-size: 0.9em;
opacity: 0.9;
}
.card-2-left-foreground-title {
order: 2; /* 排在后面 */
margin: 0;
font-weight: bold;
display: flex;
flex-direction: column; /* 让主标题和副标题垂直排列 */
}
.card-2-left-foreground-title small {
font-weight: normal;
font-size: 0.8em;
opacity: 0.8;
margin-top: 3px;
}
.card-2-right-image img {
float: right;
border-radius: 10px;
width: 250px; /* 可根据需求调整宽度 */
height: 100%;
display: flex;
align-items: center;
}
.card-2-flex-container {
display: flex;
width: 100%;
box-sizing: border-box;
}
.card-2-right-flex1 {
flex: 3;
}
.card-2-right-flex2 {
flex: 1;
margin-left: 5px;
}
@media (max-width: 768px) {
.card-2-container {
flex-direction: column; /* 改为垂直排列 */
height: auto; /* 自动适应内容高度 */
}
.card-2-left, .card-2-right {
width: 100%; /* 占满宽度 */
min-height: 200px; /* 移动端最小高度 */
}
/* 调整移动端图片大小 */
.card-2-right-image img {
float: none; /* 取消浮动 */
width: 100%; /* 图片占满宽度 */
justify-content: center; /* 水平居中 */
align-items: center; /* 垂直居中 */
}
/* 调整移动端文字大小 */
.card-2-text {
font-size: 14px;
}
.card-2_title {
font-size: 16px;
}
}