react实现一个文字三维层叠幻灯片卡片效果代码
代码语言:html
所属分类:幻灯片
代码描述:react结合react-icons实现一个文字三维层叠的卡片切换幻灯片效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <link rel='stylesheet' href='https://fonts.googleapis.com/css2?family=Montserrat:wght@400;700&display=swap'> <style> body { width: 100vw; height: 100vh; display: flex; align-items: center; justify-content: center; background-image: linear-gradient(45deg, #8B5CF6, #EC4899); font-family: "Montserrat", sans-serif; } * { box-sizing: border-box; } .carousel { position: relative; width: 23rem; height: 23rem; perspective: 500px; transform-style: preserve-3d; } .card-container { position: absolute; width: 100%; height: 100%; transform: rotateY(calc(var(--offset) * 50deg)) scaleY(calc(1 + var(--abs-offset) * -0.4)) translateZ(calc(var(--abs-offset) * -30rem)) translateX(calc(var(--offset) / var(--abs-offset) * -5rem)); filter: blur(calc(var(--abs-offset) * 1rem)); transition: all 0.3s ease-out; } .card { width: 100%; height: 100%; padding: 2rem; background-color: hsl(280deg, 40%, calc(100% - var(--abs-offset) * 50%)); border-radius: 1rem; color: #9CA3AF; text-align: justify; transition: all 0.3s ease-out; } .card h2 { text-align: center; font-size: 2rem; font-weight: bold; margin: 0 0 0.7em; color: #1F2937; } .card p, .card h2 { transition: all 0.3s ease-out; opacity: var(--active); } .nav { color: white; font-size: 5rem; position: absolute; display: flex; align-items: center; justify-content: center; top: 50%; z-index: 2; cursor: pointer; user-select: none; } .nav.left { transform: translateX(-100%) translatey(-50%); } .nav.right { right: 0; transform: translateX(100%) translatey(-50%); } </style> </head> <body > <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/react.production.17.1.js"></script> <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/react-dom.production.17.1.js"></script> <script type="module"> const { useEffect, useRef, useState} = window.React; const { render } = window.ReactDOM; import { TiChevronLeftOutline, TiChevronRightOutline } from 'https://cdn.skypack.dev/react-icons/ti'; const CARDS = 10; const MAX_VISIBILITY = 3; const Card = ({ .........完整代码请登录后点击上方下载按钮下载查看
网友评论0