跳转到内容
打开/关闭菜单
  • 1 条目
  • 2 文件
  • 8 用户
  • 590 编辑
ANACHRONISM
打开/关闭外观设置菜单
打开/关闭个人菜单
未登录
未登录用户的IP地址会在进行任意编辑后公开展示。

模板:图片交换链接/styles.css

来自ANACHRONISM
Ancimen​(留言 | 贡献)2026年10月5日 (一) 15:38的版本 (创建页面,内容为“→============================================ 图片交换链接 桌面端:悬停切换 移动端:直接显示内容层 ============================================:​ .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…”)
(差异) ←上一版本 | 最后版本 (差异) | 下一版本→ (差异)
/* ============================================
   图片交换链接
   桌面端:悬停切换
   移动端:直接显示内容层
   ============================================ */

.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__inner {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 60%;
    height: 60%;
    transform: translate(-50%, -50%);
}

/* ---- 里图片:从右上角滑入 ---- */
.pcl__image {
    position: absolute;
    inset: 0;
    opacity: 0.3;
    transform: translate(80%, -80%);
    transition: transform 0.4s ease;
}
.pcl__image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

/* ---- 文本:覆盖在里图片上 ---- */
.pcl__text {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100%;
    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); }
}