scroll-timeline实现滚动多屏页面图文飞入动画效果代码

代码语言:html

所属分类:加载滚动

代码描述:scroll-timeline实现滚动多屏页面图文飞入动画效果代码

代码标签: scroll-timeline 滚动 多屏 页面 图文 飞入 动画

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

<!DOCTYPE html>

<html lang="en">

<head>

    <meta charset="UTF-8">
<link type="text/css" rel="stylesheet" href="//repo.bfw.wiki/bfwrepo/css/normalize.5.0.css">
<link type="text/css" rel="stylesheet" href="//repo.bfw.wiki/bfwrepo/css/open-props.normalize.min.css">
<link type="text/css" rel="stylesheet" href="//repo.bfw.wiki/bfwrepo/css/open-props.min.css">


    <style>
        @import url('https://fonts.googleapis.com/css2?family=Inter:wght@900&display=swap');

        
        *,
        *:after,
        *:before {
        	box-sizing: border-box;
        }
        
        body {
        	min-height: 100vh;
        	font-family:  'Inter', sans-serif, system-ui;
          background: var(--surface-2);
          display: grid;
          justify-items: center;
          align-content: start;
          overflow-x: hidden;
        }
        
        :root {
          --content: 66ch;
          --gutter: 1rem;
          --gap: 0rem;
        }
        
        header, main {
          width: var(--content);
          max-width: calc(100vw - (2 * var(--gutter)));
          margin: 0 auto;
        }
        
        footer {
          padding: 2rem;
          font-size: 0.875rem;
        }
        
        header {
          min-height: 100vh;
          display: grid;
          align-content: center;
        }
        
        h1 {
          font-weight: 900;
          font-family: impact;
          font-size: calc(var(--font-size-fluid-3) * 2.5);
          line-height: 1;
        }
        
        .sr-only {
        	position: absolute;
          width: 1px;
          height: 1px;
          padding: 0;
          margin: -1px;
          overflow: hidden;
          clip: rect(0, 0, 0, 0);
          white-space: nowrap;
          border-width: 0;
        }
        
        header {
          position: relative;
        }
        
        header img {
          position: absolute;
          left: 25%;
          top: 15%;
          z-index: 1;
          opacity: 0.65;
          filter: saturate(0.5);
          -webkit-clip-path: polygon(0 15%, 75% 0, 100% 32%, 80% 100%, 0 67%);
                  clip-path: polygon(0 15%, 75% 0, 100% 32%, 80% 100%, 0 67%);
        }
        
        h1 {
          z-index: 2;
          position: relative;
        }
        
        h1 span:nth-of-type(2) {
          color: transparent;
          -webkit-text-stroke: 0.25rem var(--text-1);
        }
        
        section {
          display: grid;
          gap: var(--gutter);
          grid-template-columns:
            auto
            1fr;
          align-items: center;
          min-height: 100vh;
        }
        
        p:first-line {
          text-transform: uppercase;
          font-weight: bold;
        }
        
        section p {
          z-index: 2;
          background: hsl(210 17% 98% / 0.65);
          padding: 1rem;
          color: var(--text-1);
          -webkit-backdrop-filter: blur(4px);
                  backdrop-filter: blur(4px);
          font-size: 1rem;
        }
        
        @media(prefers-color-scheme: dark) {
          section p {
            background: hsl(210 11% 15% / 0.65);
          }
        }
        
        section img {
          grid-column: 1;
          width: 260px;
          max-width: 20vw;
          -webkit-clip-path: polygon(0 10%, 10% 0, 100% 0, 100% 90%, 90% 100%, 0 100%);
                  clip-path: polygon(0 10%, 10% 0, 100% 0, 100% 90%, 90% 100%, 0 100%);
          scale: 1.5;
        }
        
        section:nth-of-type(even) {
          grid-template-columns:
            1fr
            auto;
          grid-auto-flow: dense;
        }
        section:nth-of-type(even) img {
          grid-column: 2;
        }
        section:nth-of-type(even) p {
          grid-column: 1;
        }
        
        
        section {
          --x: -100%;
        }
        section:nth-of-type(even) {
          --x: 100%;
        }
        
        section img {
          view-timeline: --item;
          -webkit-animation: item-reveal both ease-in;
                  animation: item-reveal both ease-in;
          animation-timeline: --item;
          -webkit-animation-delay: cover 10%;
                  animation-delay: cover 10%;
          animation-end-delay: cover 35%;
          animation-range: cover 10% cover 35%;
        }
        
        section img {
          --y: 0;
        }
        section p {
          --x: 0;
          --y: 50%;
          view-timeline: --item;
          -webkit-animation: item-reveal both ease-out;
                  animation: item-reveal both ease-out;
          animation-timeline: --item;
          -webkit-animation-delay: cover 35%;
                  animation-delay: cover 35%;
          animation-end-delay: cover 50%;
          animation-range: cover 35% cover 50%;
          position: sticky;
          bottom: 40%;
        }
        
        @-webkit-keyframes item-reveal {
          0% {
            opacity: 0;
            translate: var(--x, 0) var(--y, 0);
          }
        }
        
        @keyframes item-reveal {
          0% {
            opacity: 0;
            translate: var(--x, 0) var(--y, 0);
          }
        }
        
        .ring-wrapper {
          --char-count: 19;
          --inner-angle: calc((360 / var(--char-count, 19)) * 1deg);
          --character-width: 1.0;
          --radius: calc((var(--character-width, 1.0) / 0.32469946920468346) * -1ch);
          --font-size: 1.5rem;
          position: fixed;
          top: 0;
          right: 0;
          height: calc((var(--character-width, 1.0) / 0.32469946920468346) * 3.5ch);
          width: calc((var(--character-width, 1.0) / 0.32469946920468346) * 3.5ch);
          translate: 0% 0%;
          display: grid;
          place-items: center;
          z-index: 10;
          border: calc(var(--character-width) * 2rem) solid var(--surface-2);
          border-radius: 50%;
          font-weight: bold;
        }
        
        .ring {
          font-family: monospace;
          text-transform: uppercase;
          font-size: calc(var(--font-size, 1) * 1rem);
          -webkit-animation: rotation 6s both linear;
                  animation: rotation 6s both linear;
          position: relative;
          animation-timeline: scroll(root);
        }
        .char {
          display: inline-block;
          position: absolute;
          top: 50%;
          left: 50%;
          transform:
            translate(-50%, -50%)
            rotate(calc(var(--inner-angle) * var(--char-index)))
            translateY(var(--radius));
        }
        @-webkit-keyframes rotation {
          to {
            rotate: 720deg;
          }
        }
        @keyframes rotation {
          to {
            rotate: 720deg;
          }
        }
    </style>




</head>

<body>
    <header>
        <img src="//repo.bfw.wiki/bfwrepo/image/6284329ddd73f.png?x-oss-process=image/auto-orient,1/resize,m_fill,w_400,h_400,/quality,q_90" alt="" width="400" height="400" />
        <h1>
            <span aria-hidden="true">Some</span>
            <span aria-hidde="true">fancy</span>
            <span aria-hidden="true">website</span>
            <span class="sr-only">Some fancy website</span>
        </h1>
    </header>
    <main>
        <section>
            <img src="//repo.bfw.wiki/bfwrepo/image/628432ce5b47a.p.........完整代码请登录后点击上方下载按钮下载查看

网友评论0