原生js+css实现电影层叠立体幻灯片效果代码
代码语言:html
所属分类:幻灯片
代码描述:原生js+css实现电影层叠立体幻灯片效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link href="https://fonts.googleapis.com/css2?family=Creepster&family=Poppins:wght@400;600;800&display=swap" rel="stylesheet"> <style> :root { --primary: #ff6b00; --primary-glow: rgba(255, 107, 0, 0.5); --secondary: #8b00ff; --secondary-glow: rgba(139, 0, 255, 0.3); --accent: #50fa7b; --accent-glow: rgba(80, 250, 123, 0.5); --bg: #13151a; /* Measurements */ --card-width: 300px; --card-height: 450px; --card-border-radius: 20px; --transition-speed: 0.5s; /* Enhanced effects */ --hover-scale: 1.05; --hover-brightness: 1.2; --glow-strength: 20px; --depth-shadow: 0 30px 60px rgba(0, 0, 0, 0.5); } * { margin: 0; padding: 0; box-sizing: border-box; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; } body { min-height: 100vh; background: var(--bg); color: white; font-family: "Poppins", sans-serif; overflow-x: hidden; cursor: none; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 2rem 1rem; perspective: 1000px; /* Added for 3D effects */ } /* Ambient Background */ .ambient-bg { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: radial-gradient( circle at center, rgba(255, 107, 0, 0.15), rgba(139, 0, 255, 0.15), rgba(80, 250, 123, 0.15) ); z-index: -2; transition: transform 0.3s ease-out; animation: ambientShift 20s ease-in-out infinite; filter: blur(40px); } /* Title Styles */ .title { font-family: "Creepster", cursive; font-size: 5rem; text-align: center; margin-bottom: 2rem; line-height: 1; position: relative; filter: drop-shadow(0 0 15px rgba(255, 107, 0, 0.3)); } .spooky { color: var(--primary); text-shadow: 0 0 var(--glow-strength) var(--primary-glow), 0 0 calc(var(--glow-strength) * 2) var(--primary-glow); display: inline-block; animation: floatText 3s ease-in-out infinite; transform-style: preserve-3d; } .classics { color: var(--accent); text-shadow: 0 0 var(--glow-strength) var(--accent-glow), 0 0 calc(var(--glow-strength) * 2) var(--accent-glow); display: inline-block; animation: floatText 3s ease-in-out infinite 0.5s; transform-style: preserve-3d; } /* Main Container */ main { width: 100%; # max-width: 1400px; margin: 0 auto; display: flex; flex-direction: column; align-items: center; transform-style: preserve-3d; } /* Carousel Styles */ .carousel-container { position: relative; width: 100%; height: var(--card-height); margin: 2rem 0; perspective: 2000px; display: flex; justify-content: center; align-items: center; transform-style: preserve-3d; } .carousel { position: relative; width: 100%; height: 100%; transform-style: preserve-3d; } /* Movie Cards */ .movie-card { position: absolute; width: var(--card-width); height: var(--card-height); transform-origin: center; transition: all var(--transition-speed) cubic-bezier(0.4, 0, 0.2, 1); cursor: none; transform-style: preserve-3d; will-change: transform, opacity; } .movie-card-inner { position: relative; width: 100%; height: 100%; border-radius: var(--card-border-radius); overflow: hidden; transform: scale(1) translateZ(0); transition: transform 0.3s ease, box-shadow 0.3s ease; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3); backdrop-filter: blur(5px); } .movie-card:hover .movie-card-inner { transform: scale(var(--hover-scale)) translateZ(50px); box-shadow: var(--depth-shadow); } .movie-poster { position: absolute; top: 0; left: 0; width: 100%; height: 100%; object-fit: cover; transition: transform 0.5s ease, filter 0.5s ease; will-change: transform; } .movie-card:hover .movie-poster { transform: scale(1.1); filter: brightness(var(--hover-brightness)); } /* Content Overlay */ .movie-content { position: absolute; bottom: 0; left: 0; width: 100%; padding: 2rem; background: linear-gradient( to top, rgba(0, 0, 0, 0.95), rgba(0, 0, 0, 0.8) 50%, transparent ); transform: translateY(70%); transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1); will-change: transform; } .movie-card:hover .movie-content { transform: translateY(0); } /* Text Styles */ .movie-title { font-size: 1.5rem; font-weight: 800; color: var(--primary); margin-bottom: 0.5rem; text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5), 0 0 20px var(--primary-glow); transition: color 0.3s ease; } /* Controls */ .controls { display: flex; gap: 1.5rem; justify-content: center; margin: 2rem 0; perspective: 1000px; } .control-btn { background: rgba(255, 255, 255, 0.1); border: 2px solid rgba(255, 255, 255, 0.2); color: white; width: 60px; height: 60px; border-radius: 50%; cursor: none; display: flex; align-items: center; justify-content: center; transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); backdrop-filter: blur(5px); transform-style: preserve-3d; } .control-btn:hover { background: rgba(255, 107, 0, 0.2); transform: scale(1.1) translateZ(20px); border-color: var(--primary); box-shadow: 0 0 20px var(--primary-glow); } /* Custom Cursor */ .custom-cursor { position: fixed; width: 20px; height: 20px; border: 2px solid var(--primary); border-radius: 50%; pointer-events: none; z-index: 9999; transition: all 0.1s ease; mix-blend-mode: difference; backdrop-filter: blur(2px); } .custom-cursor::after { content: ""; position: absolute; top: 50%; left: 50%; width: 4px; height: 4px; background: var(--primary); border-radius: 50%; transform: translate(-50%, -50%); animation: cursorPulse 2s ease-in-out infinite; } /* Animations */ @keyframes floatText { 0%, 100% { transform: translateY(0) translateZ(0); text-shadow: 0 0 var(--glow-strength) var(--primary-glow); } 50% { transform: translateY(-10px) translateZ(20px); text-shadow: 0 0 calc(var(--glow-strength) * 1.5) var(--primary-glow); } } @keyframes ambientShift { 0%, 100% { transform: scale(1); filter: hue-rotate(0deg); } 50% { transform: scale(1.1); filter: hue-rotate(30deg); } } @keyframes cursorPulse { 0%, 100% { transform: translate(-50%, -50%) scale(1); opacity: 1; } 50% { transform: translate(-50%, -50%) scale(1.5); opacity: 0.5; } } /* Media Queries */ @media (max-width: 768px) { :root { --card-width: 260px; --card-height: 400px; --glow-strength: 15px; } .title { font-size: 3rem; } .controls { gap: 1rem; } .control-btn { width: 50px; height: 50px; } } @media (max-width: 480px) { :root { --card-width: 220px; --card-height: 330px; --glow-strength: 10px; } .title { font-size: 2.5rem; } } /* Accessibility */ @media (prefers-reduced-motion: reduce) { * { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; } } .visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; } </style> </head> <body> <div class="ambient-bg"></div> <div class="particles-container"></div> <header> <h1 class="title"> <span class="spooky">Movie</span> <span class="classics">Slidr</span> </h1> </header> <main> <div class="carousel-container"> <div class="carousel" id="movieCarousel"></div> </div> <div class="controls"> <button class="control-btn" id="prevBtn" aria-label="Previous movie"> <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"> <path d="M15 18l-6-6 6-6" /> </svg> </button> <button class="control-btn" id="playBtn" aria-label="Play/Pause autoplay"> <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"> <path d="M5 3l14 9-14 9V3z" /> </svg> </button> <button class="control-btn" id="nextBtn" aria-label="Next movie"> <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"> <path d="M9 18l6-6-6-6" /> </svg> </button> </div> <div class="movie-info" id="movieInfo"> <div class="info-content"> <h2></h2> <p class="year"></p> <p class="director"></p> <p class="description"></p> <div class="rating"></div> </div> <div class="info-background"></div> </div> </main> <div class="custom-cursor"></div> <script > const movies = [ { title: "Edward Scissorhands", year: 1990, director: "Tim Burton", rating: "PG-13", description: "A gentle artificial man, who was left unfinished and has scissors for hands, leads a solitary life until a kind suburban lady discovers him.", poster: "//repo.bfw.wiki/bfwrepo/image/5fe1bc8e0ed82.png" }, { title.........完整代码请登录后点击上方下载按钮下载查看
网友评论0