模板:卡片/Cards.css:修订间差异

来自Hokubu Wiki
(目白光明Mejiro Bright移动页面模板:卡片/Card.css模板:卡片/Cards.css,不留重定向)
无编辑摘要
 
(未显示同一用户的11个中间版本)
第1行: 第1行:
/* ======================
/* ======================
   基础布局与网格系统
   基础布局与网格系统(保持不变)
   ====================== */
   ====================== */
.home-grid {
.home-grid {
   display: grid;
   display: grid;
   grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); /* 自适应列数,单卡最小300px */
   grid-template-columns: repeat(3, minmax(300px, 1fr));
   gap: 20px; /* 卡片间距 */
   gap: 20px;
   padding: 20px; /* 容器内边距 */
   padding: 20px;
   box-sizing: border-box;
   box-sizing: border-box;
}
@media (min-width: 1200px) {
  .home-grid {
    grid-template-columns: repeat(4, minmax(300px, 1fr));
  }
}
@media (max-width: 1024px) {
  .home-grid {
    grid-template-columns: repeat(2, minmax(280px, 1fr));
  }
}
@media (max-width: 768px) {
  .home-grid {
    grid-template-columns: 1fr;
    padding: 10px;
  }
  .home-card .transport-card {
    height: 150px; /* 图片高度仍可固定,不影响正文 */
  }
}
@media (max-width: 480px) {
  .home-card__header {
    font-size: 1rem;
  }
  .home-card__text,
  .home-link {
    padding: 10px;
  }
}
}


/* ======================
/* ======================
   卡片主体样式
   卡片主体样式(核心修改)
   ====================== */
   ====================== */
.home-card {
.home-card {
   overflow: hidden; /* 溢出隐藏,配合圆角 */
   overflow: hidden;
   background: var(--color-surface-2); /* 背景色(取自星际公民维基设计) */
   background: #f5f7fa;
   border: 1px solid var(--border-color-base); /* 基础边框 */
   border: 1px solid #dee2e6;
   border-radius: 15px; /* 15px圆角边框 */
   border-radius: 15px;
   box-shadow: 0 3px 6px rgba(0,0,0,0.04), 0 3px 6px rgba(0,0,0,0.0575); /* 双层阴影 */
   box-shadow: 0 3px 6px rgba(0,0,0,0.04), 0 3px 6px rgba(0,0,0,0.0575);
   transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1); /* 平滑过渡动画 */
   transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
   display: flex;
   display: flex;
   flex-direction: column; /* 垂直布局 */
   flex-direction: column;
  /* 移除 height: 100%,改为默认 auto,让卡片高度随内容自适应 */
  /* height: 100%; 删掉这行 */
}
}


/* 卡片悬停效果 */
.home-card:hover {
.home-card:hover {
   transform: translateY(-5px); /* 上移5px */
   transform: translateY(-5px);
   border-color: var(--color-primary); /* 边框变为主题色 */
   border-color: #3498db;
   box-shadow: 0 10px 20px rgba(0,0,0,0.1); /* 加深阴影 */
   box-shadow: 0 10px 20px rgba(0,0,0,0.1);
}
}


/* ======================
/* ======================
   卡片内容区域样式
   卡片内容区域样式(核心修改)
   ====================== */
   ====================== */
/* 标题区域 */
.home-card__header {
.home-card__header {
   margin: 0;
   margin: 0;
   padding: 15px 20px; /* 内边距 */
   padding: 15px 20px;
   background: var(--color-surface-3); /* 次级背景色 */
   background: #e9ecef;
   border-bottom: 1px solid var(--border-color-base); /* 底部边框 */
   border-bottom: 1px solid #dee2e6;
   font-size: 1.2rem; /* 标题字号 */
   font-size: 1.2rem;
   font-weight: bold; /* 粗体 */
   font-weight: bold;
}
}


/* 图片容器 */
.home-card .transport-card {
.home-card .transport-card {
   position: relative;
   position: relative;
   height: 180px; /* 图片高度 */
   height: 180px; /* 图片高度可固定,不影响正文自适应 */
   margin: 0;
   margin: 0;
   border: none !important; /* 移除默认边框 */
   border: none !important;
}
}


.home-card .transport-image {
.home-card .transport-image {
   position: absolute;
   position: absolute;
   inset: 0; /* 等价于top/right/bottom/left:0 */
   inset: 0;
   margin: 0;
   margin: 0;
   border-radius: 0; /* 图片区域无边角 */
   border-radius: 0;
   overflow: hidden; /* 图片溢出隐藏 */
   overflow: hidden;
}
}


第63行: 第94行:
   width: 100%;
   width: 100%;
   height: 100%;
   height: 100%;
   object-fit: cover; /* 保持比例覆盖容器 */
   object-fit: cover;
   transition: transform 0.5s cubic-bezier(0, 0.8, 0.2, 1); /* 图片缩放动画 */
   transition: transform 0.5s cubic-bezier(0, 0.8, 0.2, 1);
}
}


/* 图片悬停放大效果 */
.home-card .transport-image img:hover {
.home-card .transport-image img:hover {
   transform: scale(1.1); /* 放大1.1倍 */
   transform: scale(1.1);
}
}


/* 文本内容区域 */
/* 文本内容区域:解除高度限制 */
.home-card__text {
.home-card__text {
   margin: 0;
   margin: 0;
   padding: 15px 20px; /* 内边距 */
   padding: 15px 20px;
   line-height: 1.6; /* 行高 */
  line-height: 1.6;
   flex-grow: 1; /* 自动填充剩余空间,保证卡片高度一致 */
  flex-grow: 1; /* 保留flex特性,让文本区域填充剩余空间(但不限制最大高度) */
   /* 删掉以下两行限制,让文本高度随内容自然扩展 */
  /* max-height: 76.8px; */
  /* overflow: hidden; */
   position: relative;
}
 
/* 移除文本区域的渐变遮罩(因为内容不再被隐藏) */
.home-card__text::after {
  display: none; /* 删掉渐变遮罩,避免无意义的覆盖 */
}
}


/* ======================
  按钮与交互样式
  ====================== */
/* 链接按钮容器 */
.home-link {
.home-link {
   margin: 0 20px 15px; /* 边距 */
   margin: 0 20px 15px;
   text-align: center; /* 居中对齐 */
   text-align: center;
}
}


/* 按钮样式 */
.home-link__button {
.home-link__button {
   display: inline-block;
   display: inline-block;
   padding: 8px 16px; /* 内边距 */
   padding: 8px 16px;
   background: var(--color-primary); /* 主题色背景 */
   background: #3498db;
   color: white; /* 白色文字 */
   color: white;
   border-radius: 8px; /* 圆角 */
   border-radius: 8px;
   text-decoration: none; /* 移除下划线 */
   text-decoration: none;
   transition: background 0.3s ease; /* 背景色过渡动画 */
   transition: background 0.3s ease;
   font-weight: 600; /* 半粗体 */
   font-weight: 600;
}
}


/* 按钮悬停效果 */
.home-link__button:hover {
.home-link__button:hover {
   background: var(--color-primary--hover); /* 深一级主题色 */
   background: #2980b9;
}
 
/* 覆盖按钮内 MediaWiki 链接的默认样式 */
.home-link__button a {
  color: white !important; /* 强制文本为白色,与按钮背景匹配 */
  text-decoration: none !important; /* 移除默认下划线 */
  display: inline-block; /* 确保链接占据按钮完整区域(可选) */
}
 
/* 悬停时保持样式一致(可选) */
.home-link__button a:hover {
  color: white !important;
  text-decoration: none !important;
}
}


/* ======================
/* ======================
   响应式布局适配
   暗色模式适配样式(修改为 skin-citizen-dark 触发)
   ====================== */
   ====================== */
/* 中等屏幕(1024px以下) */
html.skin-citizen-dark .home-card {
@media (max-width: 1024px) {
  background: #1e1e2e; /* 深色背景 */
   .home-grid {
  border-color: #373747; /* 深色边框 */
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); /* 缩小单卡最小宽度 */
  box-shadow: 0 3px 6px rgba(0,0,0,0.2), 0 3px 6px rgba(0,0,0,0.25); /* 深色环境增强阴影 */
   }
}
 
html.skin-citizen-dark .home-card:hover {
   border-color: #4a90e2; /* 暗色模式下悬停边框色调整 */
}
 
html.skin-citizen-dark .home-card__header {
  background: #2d2d3f; /* 标题栏深色背景 */
  border-bottom-color: #373747; /* 标题栏底部边框 */
  color: #e0e0f5; /* 标题文本色(浅色) */
}
 
html.skin-citizen-dark .home-card__text {
  color: #d0d0e0; /* 正文浅色文本,确保在深色背景上可读 */
}
 
html.skin-citizen-dark .home-link__button {
   background: #4a90e2; /* 稍亮的蓝色按钮,增强对比度 */
}
}


/* 小屏幕(768px以下) */
html.skin-citizen-dark .home-link__button:hover {
@media (max-width: 768px) {
  background: #357abd; /* 悬停时加深 */
  .home-grid {
    grid-template-columns: 1fr; /* 单栏布局 */
    padding: 10px; /* 缩小内边距 */
  }
 
  .home-card .transport-card {
    height: 150px; /* 缩小图片高度 */
  }
}
}


/* 超小屏幕(480px以下) */
html.skin-citizen-dark .home-link__button a {
@media (max-width: 480px) {
   color: #ffffff !important; /* 白色文本,确保清晰 */
  .home-card__header {
    font-size: 1rem; /* 缩小标题字号 */
  }
 
  .home-card__text,
   .home-link {
    padding: 10px; /* 缩小内容内边距 */
  }
}
}

2025年7月26日 (六) 23:53的最新版本

/* ======================
   基础布局与网格系统(保持不变)
   ====================== */
.home-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(300px, 1fr));
  gap: 20px;
  padding: 20px;
  box-sizing: border-box;
}

@media (min-width: 1200px) {
  .home-grid {
    grid-template-columns: repeat(4, minmax(300px, 1fr));
  }
}

@media (max-width: 1024px) {
  .home-grid {
    grid-template-columns: repeat(2, minmax(280px, 1fr));
  }
}

@media (max-width: 768px) {
  .home-grid {
    grid-template-columns: 1fr;
    padding: 10px;
  }
  .home-card .transport-card {
    height: 150px; /* 图片高度仍可固定,不影响正文 */
  }
}

@media (max-width: 480px) {
  .home-card__header {
    font-size: 1rem;
  }
  .home-card__text,
  .home-link {
    padding: 10px;
  }
}

/* ======================
   卡片主体样式(核心修改)
   ====================== */
.home-card {
  overflow: hidden;
  background: #f5f7fa;
  border: 1px solid #dee2e6;
  border-radius: 15px;
  box-shadow: 0 3px 6px rgba(0,0,0,0.04), 0 3px 6px rgba(0,0,0,0.0575);
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
  /* 移除 height: 100%,改为默认 auto,让卡片高度随内容自适应 */
  /* height: 100%; 删掉这行 */
}

.home-card:hover {
  transform: translateY(-5px);
  border-color: #3498db;
  box-shadow: 0 10px 20px rgba(0,0,0,0.1);
}

/* ======================
   卡片内容区域样式(核心修改)
   ====================== */
.home-card__header {
  margin: 0;
  padding: 15px 20px;
  background: #e9ecef;
  border-bottom: 1px solid #dee2e6;
  font-size: 1.2rem;
  font-weight: bold;
}

.home-card .transport-card {
  position: relative;
  height: 180px; /* 图片高度可固定,不影响正文自适应 */
  margin: 0;
  border: none !important;
}

.home-card .transport-image {
  position: absolute;
  inset: 0;
  margin: 0;
  border-radius: 0;
  overflow: hidden;
}

.home-card .transport-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.5s cubic-bezier(0, 0.8, 0.2, 1);
}

.home-card .transport-image img:hover {
  transform: scale(1.1);
}

/* 文本内容区域:解除高度限制 */
.home-card__text {
  margin: 0;
  padding: 15px 20px;
  line-height: 1.6;
  flex-grow: 1; /* 保留flex特性,让文本区域填充剩余空间(但不限制最大高度) */
  /* 删掉以下两行限制,让文本高度随内容自然扩展 */
  /* max-height: 76.8px; */
  /* overflow: hidden; */
  position: relative;
}

/* 移除文本区域的渐变遮罩(因为内容不再被隐藏) */
.home-card__text::after {
  display: none; /* 删掉渐变遮罩,避免无意义的覆盖 */
}

.home-link {
  margin: 0 20px 15px;
  text-align: center;
}

.home-link__button {
  display: inline-block;
  padding: 8px 16px;
  background: #3498db;
  color: white;
  border-radius: 8px;
  text-decoration: none;
  transition: background 0.3s ease;
  font-weight: 600;
}

.home-link__button:hover {
  background: #2980b9;
}

/* 覆盖按钮内 MediaWiki 链接的默认样式 */
.home-link__button a {
  color: white !important; /* 强制文本为白色,与按钮背景匹配 */
  text-decoration: none !important; /* 移除默认下划线 */
  display: inline-block; /* 确保链接占据按钮完整区域(可选) */
}

/* 悬停时保持样式一致(可选) */
.home-link__button a:hover {
  color: white !important;
  text-decoration: none !important;
}

/* ======================
   暗色模式适配样式(修改为 skin-citizen-dark 触发)
   ====================== */
html.skin-citizen-dark .home-card {
  background: #1e1e2e; /* 深色背景 */
  border-color: #373747; /* 深色边框 */
  box-shadow: 0 3px 6px rgba(0,0,0,0.2), 0 3px 6px rgba(0,0,0,0.25); /* 深色环境增强阴影 */
}

html.skin-citizen-dark .home-card:hover {
  border-color: #4a90e2; /* 暗色模式下悬停边框色调整 */
}

html.skin-citizen-dark .home-card__header {
  background: #2d2d3f; /* 标题栏深色背景 */
  border-bottom-color: #373747; /* 标题栏底部边框 */
  color: #e0e0f5; /* 标题文本色(浅色) */
}

html.skin-citizen-dark .home-card__text {
  color: #d0d0e0; /* 正文浅色文本,确保在深色背景上可读 */
}

html.skin-citizen-dark .home-link__button {
  background: #4a90e2; /* 稍亮的蓝色按钮,增强对比度 */
}

html.skin-citizen-dark .home-link__button:hover {
  background: #357abd; /* 悬停时加深 */
}

html.skin-citizen-dark .home-link__button a {
  color: #ffffff !important; /* 白色文本,确保清晰 */
}