模板:图片交换链接/styles.css:修订间差异
来自ANACHRONISM
更多操作
创建页面,内容为“→============================================ 图片交换链接 桌面端:悬停切换 移动端:直接显示内容层 ============================================: .pcl { position: relative; overflow: hidden; box-shadow: 0 0 0.5em rgba(0, 0, 0, 0.8); } →---- 表层图片:默认可见 ----: .pcl__surface { position: absolute; inset: 0; transition: opacity 0.4s ease; z-index: 2; } .pcl__surface img { w…” |
无编辑摘要 |
||
| 第32行: | 第32行: | ||
transition: opacity 0.4s ease; | transition: opacity 0.4s ease; | ||
z-index: 1; | z-index: 1; | ||
} | } | ||
/* ---- | /* ---- 里图片:占满卡片,从右上滑入 ---- */ | ||
.pcl__image { | .pcl__image { | ||
position: absolute; | position: absolute; | ||
inset: 0; | inset: 0; | ||
opacity: 0.3; | opacity: 0.3; | ||
transform: translate( | transform: translate(40%, -40%); | ||
transition: transform 0.4s ease; | transition: transform 0.4s ease; | ||
} | } | ||
| 第53行: | 第45行: | ||
width: 100%; | width: 100%; | ||
height: 100%; | height: 100%; | ||
object-fit: | object-fit: cover; | ||
display: block; | display: block; | ||
} | } | ||
| 第62行: | 第54行: | ||
top: 50%; | top: 50%; | ||
left: 50%; | left: 50%; | ||
width: | width: 60%; | ||
transform: translate(-50%, calc(-50% + 0.8em)); | transform: translate(-50%, calc(-50% + 0.8em)); | ||
text-align: center; | text-align: center; | ||
2026年10月5日 (一) 15:40的版本
/* ============================================
图片交换链接
桌面端:悬停切换
移动端:直接显示内容层
============================================ */
.pcl {
position: relative;
overflow: hidden;
box-shadow: 0 0 0.5em rgba(0, 0, 0, 0.8);
}
/* ---- 表层图片:默认可见 ---- */
.pcl__surface {
position: absolute;
inset: 0;
transition: opacity 0.4s ease;
z-index: 2;
}
.pcl__surface img {
width: 100%;
height: 100%;
object-fit: cover;
display: block;
}
/* ---- 内容层:默认隐藏 ---- */
.pcl__content {
position: absolute;
inset: 0;
opacity: 0;
transition: opacity 0.4s ease;
z-index: 1;
}
/* ---- 里图片:占满卡片,从右上滑入 ---- */
.pcl__image {
position: absolute;
inset: 0;
opacity: 0.3;
transform: translate(40%, -40%);
transition: transform 0.4s ease;
}
.pcl__image img {
width: 100%;
height: 100%;
object-fit: cover;
display: block;
}
/* ---- 文本:覆盖在里图片上 ---- */
.pcl__text {
position: absolute;
top: 50%;
left: 50%;
width: 60%;
transform: translate(-50%, calc(-50% + 0.8em));
text-align: center;
font-size: 1em;
line-height: 1.2;
z-index: 1;
}
.pcl__text a {
color: inherit;
}
/* ---- 悬停切换 ---- */
.pcl:hover .pcl__surface {
opacity: 0;
}
.pcl:hover .pcl__content {
opacity: 1;
}
.pcl:hover .pcl__image {
transform: translate(0, 0);
}
/* ---- 移动端:直接显示内容层 ---- */
@media (hover: none) {
.pcl__surface { opacity: 0; }
.pcl__content { opacity: 1; }
.pcl__image { transform: translate(0, 0); }
}