gsap实现鼠标滚动横向相册效果代码

代码语言:html

所属分类:画廊相册

代码描述:gsap实现鼠标滚动横向相册效果代码,结合了ScrollSmoother、ScrollTrigger、gsap、SplitText3

代码标签: gsap 鼠标 滚动 横向 相册

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


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

<head>

  <meta charset="UTF-8">
  

  <meta name="viewport" content="width=device-width, initial-scale=1">
<link type="text/css" rel="stylesheet" href="//repo.bfw.wiki/bfwrepo/css/normalize.5.0.css">

  
  
<style>
@import url("https://fonts.googleapis.com/css2?family=Signika+Negative:wght@400;600&display=swap");

header, footer, #smooth-content {
  visibility: hidden;
}

html,
body {
  padding: 0;
  margin: 0;
}
body {
  position: relative;
  overflow-x: hidden;
  background-color: #161616;
  font-family: "Signika Negative", sans-serif;
  color: white;
}

header {
  box-sizing: border-box;
  position: fixed;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 5%;
  width: 100%;
  z-index: 3;
  height: 7em;
  font-size: clamp(0.66rem, 2vw, 1rem);
  letter-spacing: 0.2em;
}

.heading {
  position: fixed;
  margin: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 100%;
  text-align: center;
  font-weight: 600;
  opacity: 0;
}

.heading h1 {
  font-size: 12vw;
}

#container {
  display: flex;
  flex-wrap: wrap;
  flex-direction: column;
  height: 100vh;
  will-change: transform;
}

.section {
  position: relative;
  width: 50vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  transform: perspective(400px);
  transform-style: preserve-3d;
   max-width: 500px;
}

.hide {
  overflow: hidden;
  margin-top: 1.2rem;
}

h1, h2 {
  margin: 0;
}

h1 > *, h2 > * {
  will-change: transform;
}

h2 {
  font-size: clamp(0.66rem, 3vw, 2.5rem);
  margin: 0;
}

p {
  margin-top: 0.5rem;
  opacity: 0.4;
}

.section--lg, .end {
  min-width: 100vw;
}

.card {
  width: 80%;
  z-index: 999;
}

.card img {
  width: 100%;
  aspect-ratio: 16/9;
  object-fit: cover;
}

.section:nth-child(2n) {
  margin-top: -10vh;
}

.section:nth-child(3n) {
  margin-top: 30vh;
}

.........完整代码请登录后点击上方下载按钮下载查看

网友评论0