css实现页面滚动粘性头部导航条效果代码

代码语言:html

所属分类:加载滚动

代码描述:css实现页面滚动粘性头部导航条效果代码

代码标签: css 页面 滚动 粘性 头部 导航条

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

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

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

  
  
<style>
@import url("https://fonts.googleapis.com/css2?family=Montserrat:wght@100..700&display=swap");
@supports (animation-timeline: view()) {
  @keyframes fade-out {
    to {
      background-size: 150%;
      opacity: 0;
    }
  }
  @keyframes zoom-out {
    to {
      font-size: 2rem;
      padding-left: 0.1em;
    }
  }
  @keyframes appear {
    to {
      opacity: 1;
    }
  }
  @keyframes max-out {
    to {
      max-width: 100%;
    }
  }
  .hero {
    animation: fade-out linear both;
    animation-timeline: view();
    animation-range: exit -100px;
  }

  nav {
    animation: max-out linear both;
    animation-timeline: view();
    animation-range-start: 80vh;
    animation-range-end: 100vh;
  }

  nav:after {
    animation: appear linear both;
    animation-timeline: view();
    animation-range-start: 60vh;
    animation-range-end: 100vh;
  }

  .logo {
    animation: zoom-out linear both;
    animation-timeline: view();
    animation-range-start: 10vh;
    animation-range-end: 100vh;
  }
}
body {
  font-family: "Montserrat", sans-serif;
  font-size: 1rem;
  margin: 0;
  background-color: #1f2020;
  color: #F9F6EF;
}

.hero, nav, main {
  max-width: 75ch;.........完整代码请登录后点击上方下载按钮下载查看

网友评论0