背景悬浮切换导航效果

代码语言:html

所属分类:菜单导航

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

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">

<link href="https://fonts.googleapis.com/css?family=Trocchi|Anton" rel="stylesheet">

<style>
:root {
  --purple-brown: #231f20;
  --egg-shell: #e8e4d2;
  --dark-peach: #e26961;
  --border-width: .75rem;
  --dots-gap: 10px;
}

*, *:before, *:after {
  box-sizing: border-box;
}

body {
  font-family: Trocchi, Georgia, serif;
  line-height: 1.5;
  color: var(--egg-shell);
}

a {
  color: inherit;
}

.bg {
  background: inherit;
  min-height: 100vh;
  padding: 25vh 0 1.5rem;
  -webkit-transition: background 0s 1s, color .6s;
  transition: background 0s 1s, color .6s;
}

.projects {
  color: var(--purple-brown);
}

.bg:after {
  content: "";
  border: var(--border-width) solid;
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  right: 0;
  z-index: 12;
  pointer-events: none;
  -webkit-transition: 1s;
  transition: 1s;
}

.bio,
.link-bio {
  background: var(--purple-brown);
}

.bio h1 {
  background-color: var(--dark-peach);
}

.projects,
.link-projects {
  background: var(--egg-shell);
}

.find-me,
.link-find-me {
  background: var(--dark-peach);
}

.transition {
  width: 1rem;
  height: 1rem;
  top: 0;
  display: block;
  position: absolute;
  opacity: 0;
  -webkit-transition: -webkit-transform .6s ease-in-out;
  transition: -webkit-transform .6s ease-in-out;
  transition: transform .6s ease-in-out;
  transition: transform .6s ease-in-out, -webkit-transform .6s ease-in-out;
  width: 100%;
  height: 100vh;
  -webkit-transform: scale(0.1);
          transform: scale(0.1);
  -webkit-transform-origin: 0 0;
          transform-origin: 0 0;
}

.transition-bio {
  left: 0;
  background: var(--purple-brown);
}

.transition-projects {
  left: 7.5rem;
  background: var(--egg-shell);
}

.transition-find-me {
  left: 15rem;
  background: var(--dark-peach);
}

.bio .transition-bio,
.projects .transition-projects,
.find-me .transition-find-me {
  opacity: 1;
}

.bio .transition-bio {
  -webkit-transform: scale(1);
          transform: scale(1);
}

.projects .transition-projects {
  -webkit-transform: scale(1) translateX(-7.5rem);
          transform: scale(1) translateX(-7.5rem);
}

.find-me .transition-find-me {
  -webkit-transform: scale(1) translateX(-15rem);
          transform: scale(1) translateX(-15rem);
}

.dots:before,
.dots:after {
  content: "";
  position: fixed;
  top: 0;
  bottom: 0;
  opacity: .5;
  z-index: 11;
  background-image: -webkit-gradient(linear, left top, left bottom, color-stop(20%, var(--dark-peach)), color-stop(0, transparent));
  background-image: linear-gradient(var(--dark-peach) 20%, transparent 0);
  background-size: 100% var(--dots-gap);
  background-position: 0 0;
  -webkit-animation: movebg .2s linear infinite;
          animation: movebg .2s linear infinite;
  will-change: transform;
  width: 2px;
}

.dots1:before {
  left: 5%;
}

.dots1:after {
  left: 15%;
}

.dots2:before {
  right: 75%;
}

.dots2:after {
  right: 5%;
}

.dots:after {
  animation-direction: reverse;
}

.projects .dots:before,
.projects .dots:after {
  background-image: -webkit-gradient(linear, left top, left bottom, color-stop(20%, var(--purple-brown)), color-stop(0, transparent));
  background-image: linear-gradient(var(--purple-brown) 20%, transparent 0);
}

.find-me .dots:before,
.find-me .dots:after {
  background-image: -webkit-gradient(linear, left top, left bottom, color-stop(20%, var(--egg-shell)), color-stop(0, transparent));
  background-image: linear-gradient(var(--egg-shell) 20%, transparent 0);
}

@-webkit-keyframes movebg {
  0% {
    -webkit-transform: translate3d(0, 0, 0);
            transform: translate3d(0, 0, 0);
  }
  100% {
    -webkit-transform: translate3d(0, var(--dots-gap), 0);
            transform: translate3d(0, var(--dots-gap), 0);
  }
}

@keyframes movebg {
  0% {
    -webkit-transform: translate3d(.........完整代码请登录后点击上方下载按钮下载查看

网友评论0