模板:MCPlayerInfo:修订间差异

来自Hokubu Wiki
无编辑摘要
无编辑摘要
标签已被回退
第1行: 第1行:
<includeonly>
/* ======================
{{#if: {{{start|}}}|
  基础布局与网格系统
<div class="mc-player-grid">
  ====================== */
|}}
.home-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(300px, 1fr)); /* 默认三列 */
  gap: 20px; /* 卡片间距 */
  padding: 20px; /* 容器内边距 */
  box-sizing: border-box;
}


<templatestyles src="Template:MCPlayerInfo/style.css" />
/* 大屏幕(1200px以上)显示四列 */
<a href="/wiki/{{{name|}}}" class="mc-player-card">
@media (min-width: 1200px) {
    <!-- 头像区域 -->
  .home-grid {
    <div class="mc-player-avatar">
     grid-template-columns: repeat(4, minmax(300px, 1fr));
        <img src="{{{image|https://picsum.photos/200/200?random=1}}}"
  }
            alt="{{{name|}}}的头像" />
}
    </div>
   
    <!-- 文字信息区域 -->
     <div class="mc-player-info">
        <div class="mc-player-name">{{{name|}}}</div>
        <div class="mc-player-chinese">{{{chinese|}}}</div>
        <div class="mc-player-english">{{{english|}}}</div>
    </div>
</a>


{{#if: {{{end|}}}|
/* 中等屏幕(1024px以下)切换为两列 */
</div>
@media (max-width: 1024px) {
|}}
  .home-grid {
</includeonly>
    grid-template-columns: repeat(2, minmax(280px, 1fr));
  }
}


<noinclude>
/* 小屏幕(768px以下)切换为单列 */
== 玩家信息卡片模板 ==
@media (max-width: 768px) {
横向卡片风格,与参考样式统一,支持网格布局和交互效果。
  .home-grid {
    grid-template-columns: 1fr;
    padding: 10px;
  }
  .home-card .transport-card {
    height: 150px; /* 缩小图片高度 */
  }
}


== 使用方法 ==
/* 超小屏幕(480px以下)优化内边距 */
{{MCPlayerInfo|start=1}}
@media (max-width: 480px) {
{{MCPlayerInfo
  .home-card__header {
| name    = Notch
    font-size: 1rem; /* 缩小标题字号 */
| chinese = 马库斯·阿列克谢·泊松
  }
| english = Creator of Minecraft
  .home-card__text,
| image   = Notch_Avatar.png
   .home-link {
}}
    padding: 10px; /* 缩小内容内边距 */
{{MCPlayerInfo
   }
| name    = Jeb_
}
| chinese = 延斯·伯根斯坦
| english = Lead Developer
| image   = Jeb_Avatar.png
}}
{{MCPlayerInfo|end=1}}


== 参数说明 ==
/* ======================
* '''start=1''' - 列表开头,初始化网格容器
  卡片主体样式
* '''end=1''' - 列表结尾,闭合网格容器
  ====================== */
* '''name''' (必填) - 玩家名称(链接目标)
.home-card {
* '''chinese''' (选填) - 中文介绍
  overflow: hidden; /* 溢出隐藏,配合圆角 */
* '''english''' (选填) - 英文介绍
  background: #f5f7fa; /* 背景色 */
* '''image''' (选填) - 头像图片URL(本地文件直接填文件名,如 "Notch.png")
  border: 1px solid #dee2e6; /* 边框色 */
</noinclude>
  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%; /* 确保卡片高度一致 */
}
 
/* 卡片悬停效果 */
.home-card:hover {
  transform: translateY(-5px); /* 上移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); /* 放大1.1倍 */
}
 
/* 文本内容区域 */
.home-card__text {
  margin: 0;
  padding: 15px 20px; /* 内边距 */
  line-height: 1.6; /* 行高 */
  flex-grow: 1; /* 自动填充剩余空间 */
  max-height: 76.8px; /* 3行文本高度(1.6*16*3) */
  overflow: hidden; /* 超出隐藏 */
  position: relative; /* 为伪元素定位 */
}
 
/* 渐变遮罩(可选) */
.home-card__text::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 30px;
  background: linear-gradient(to bottom, rgba(245,247,250,0) 0%, rgba(245,247,250,1) 100%);
  pointer-events: 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; /* 深一级主题色 */
}

2025年7月25日 (五) 23:53的版本

/* ======================

  基础布局与网格系统
  ====================== */

.home-grid {

 display: grid;
 grid-template-columns: repeat(3, minmax(300px, 1fr)); /* 默认三列 */
 gap: 20px; /* 卡片间距 */
 padding: 20px; /* 容器内边距 */
 box-sizing: border-box;

}

/* 大屏幕(1200px以上)显示四列 */ @media (min-width: 1200px) {

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

}

/* 中等屏幕(1024px以下)切换为两列 */ @media (max-width: 1024px) {

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

}

/* 小屏幕(768px以下)切换为单列 */ @media (max-width: 768px) {

 .home-grid {
   grid-template-columns: 1fr;
   padding: 10px;
 }
 .home-card .transport-card {
   height: 150px; /* 缩小图片高度 */
 }

}

/* 超小屏幕(480px以下)优化内边距 */ @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%; /* 确保卡片高度一致 */

}

/* 卡片悬停效果 */ .home-card:hover {

 transform: translateY(-5px); /* 上移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); /* 放大1.1倍 */

}

/* 文本内容区域 */ .home-card__text {

 margin: 0;
 padding: 15px 20px; /* 内边距 */
 line-height: 1.6; /* 行高 */
 flex-grow: 1; /* 自动填充剩余空间 */
 max-height: 76.8px; /* 3行文本高度(1.6*16*3) */
 overflow: hidden; /* 超出隐藏 */
 position: relative; /* 为伪元素定位 */

}

/* 渐变遮罩(可选) */ .home-card__text::after {

 content: "";
 position: absolute;
 bottom: 0;
 left: 0;
 right: 0;
 height: 30px;
 background: linear-gradient(to bottom, rgba(245,247,250,0) 0%, rgba(245,247,250,1) 100%);
 pointer-events: 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; /* 深一级主题色 */

}