原生js+css实现视觉差异图片幻灯片 效果代码

代码语言:html

所属分类:幻灯片

代码描述:原生js+css实现视觉差异图片幻灯片 效果代码

代码标签: 原生 js css 视觉 差异 图片 幻灯片

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

<!DOCTYPE html>
<html lang="en" >

<head>
  <meta charset="UTF-8">
  

  <meta name="viewport" content="width=device-width, initial-scale=1">
  
  
  
<style>
* {
  box-sizing: border-box;
}
:root {
  --mzaC-fg: #e7ecf2;
  --mzaC-accent: #9ef7d2;
  --mzaC-accent2: #82a0ff;
  --mzaC-glass: rgba(255, 255, 255, 0.06);
  --mzaC-glow: rgba(130, 160, 255, 0.75);
  --mzaC-slideW: min(880px, 90vw);
  --mzaC-peek: 0.15;
  --mzaPagH: 64px;
  --mzaCardH: clamp(360px, 62vh, 600px);
}
html,
body {
  height: 100%;
  margin: 0;
  overflow: hidden;
}
body {
  background: radial-gradient(
      1200px 600px at 10% -10%,
      #1a2140 0%,
      transparent 40%
    ),
    radial-gradient(900px 600px at 110% 10%, #0e3d3f 0%, transparent 40%),
    linear-gradient(180deg, #0a0d12 0%, #0c1117 100%);
  color: var(--mzaC-fg);
  font: 16px/1.4 system-ui, Segoe UI, Roboto, Ubuntu, "Helvetica Neue", Arial;
}
.mzaCarousel {
  position: relative;
  height: 100vh;
  max-width: 100vw;
  margin: 0 auto;
  padding: 0 18px;
  overflow: hidden;
  contain: layout paint;
  touch-action: none;
}
.mzaCarousel-viewport {
  position: relative;
  outline: none;
  overflow: hidden;
  height: 100%;
}
.mzaCarousel-track {
  position: relative;
  height: calc(100% - var(--mzaPagH) - max(env(safe-area-inset-bottom), 12px));
  transform-style: preserve-3d;
  perspective: 1200px;
  overflow: hidden;
}
.mzaCarousel-slide {
  position: absolute;
  top: calc(50% + 5px);
  left: 50%;
  width: var(--mzaC-slideW);
  height: min(var(--mzaCardH), calc(100% - 50px));
  transform-style: preserve-3d;
  display: grid;
  place-items: center;
  border-radius: 22px;
  overflow: hidden;
  will-change: transform, filter;
}
.mzaCard {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  overflow: hidden;
  background: var(--mzaC-glass);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
  backdrop-filter: saturate(120%) blur(4px);
  transform: translateZ(0);
  cursor: grab;
}
.mzaCard::before {
  content: "";
  position: absolute;
  inset: -2%;
  background-image: var(--mzaCard-bg);
  background-size: cover;
  background-position: center;
  filter: contrast(1.02) saturate(1.08) brightness(0.9);
  transform: translateZ(-60px) scale(1.18)
    translate3d(var(--mzaParBgX, 0px), var(--mzaParBgY, 0px), 0);
  transition: transform 800ms cubic-bezier(0.2, 0.7, 0, 1),
    filter 800ms cubic-bezier(0.2, 0.7, 0, 1);
}
.mzaCard::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    rgba(0, 0, 0, 0.25),
    rgba(0, 0, 0, 0.45) 45%,
    rgba(0, 0, 0, 0.25) 100%
  );
}
.mzaCard-head {
  position: absolute;
  inset: 20px auto auto 20px;
  z-index: 2;
}
.mzaCard-title {
  margin: 0;
  font-weight: 800;
  letter-spacing: 0.2px;
  font-size: clamp(22px, 3.1vw, 38px);
  text-shadow: 2px 2px 15px rgba(0, 0, 0, 0.6);
  line-height: 110%;
  cursor: text;
}
.mzaCard-kicker {
  margin: 0.5rem 0;
  color: var(--mzaC-accent);
  font-size: clamp(12px, 1.7vw, 14px);
  font-weight: 600;
  text-shadow: 1px 1px 10px rgba(0, 0, 0, 0.6);
  cursor: text;
}
.mzaCard-text {
  display: -webkit-box;
  line-clamp: 3;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  position: absolute;
  inset: auto 20px 85px 20px;
  z-index: 2;
  max-width: 60ch;
  background-color: rgba(0, 0, 0, 0.4);
  padding: 20px;
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  border-radius: 10px;
  text-wrap: balance;
  cursor: text;
  color: #ddd;
  overflow: hidden;
}
.mzaCard-actions {
  position: absolute;
  inset: auto auto 18px 18px;
  z-index: 2;
}
.mzaBtn {
  appearance: none;
  border: 1px solid #9ef7d2;
  border-radius: 14px;
  padding: 15px 20px;
  font-weight: 700;
  color: #0b0e13;
  background-image: linear-gradient(
    180deg,
    #9ef7d2,
    #97ebc8,
    #8fe0be,
    #88d5b5,
    #81c9ab,
    #7abea2,
    #73b398,
    #6ca88f,
    #659d86,
    #5e937d,
    #588874,
    #517e6b
  );
  box-shadow: 0 3px 15px var(--mzaC-glow);
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2.........完整代码请登录后点击上方下载按钮下载查看

网友评论0