js+css实现粘性头部阴影导航条菜单效果代码

代码语言:html

所属分类:菜单导航

代码描述:js+css实现粘性头部阴影导航条菜单效果代码

代码标签: js css 粘性 头部 阴影 导航条 菜单

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

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

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

<link type="text/css" rel="stylesheet" href="//repo.bfw.wiki/bfwrepo/css/reset.min.css">
  
<style>
header {
  position: sticky;
  top: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 1rem;
  padding: 2rem clamp(1rem, 4vw, 2rem);
  background-color: white;
  transition: box-shadow 200ms cubic-bezier(0.33, 1, 0.68, 1);
}

header.active {
  box-shadow: hsla(0 0% 0% / 0.1) 0 0.5rem 1rem;
  transition-duration: 400ms;
}

.site-name {
  font-weight: bold;
}

.menu {
  display: flex;
  gap: 1rem;
}

.menu a {
  color: inherit;
  text-decoration: none;
}

main {
  height: 300vh;
  -webkit-margin-before: 5rem;
          margin-block-start: 5rem;
  text-align: center;
}

body {
  font-family: system-ui, sans-serif;

  /* Easing gradient: https://larsenwork.com/easing-gradients/ */
  background: linear-gradient(
    to bottom,
    hsl(0, 0%, 100%) 0%,
    hsl(219.19, 55.23%, 99.76%) 10.6%,
    hsl(219.13, 55.37%, 99.05%) 20%,
    hsl(219.05, 55.59%, 97.92%) 28.4%,
    hsl(218.92, 55.89%, 96.39%) 35.8%,
    hsl(218.76, 56.28%, 94.49%) 42.6%,
    hsl(218.55, 56.76%, 92.22%) 48.7%,
    hsl(218.29, 57.33%, 89.61%) 54.4%,
    hsl(217.96, 58%, 86.67%) 59.8%,
    .........完整代码请登录后点击上方下载按钮下载查看

网友评论0