svg菜单动画效果

代码语言:html

所属分类:菜单导航

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

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

<title> - SVG Icon Animations 1</title>
<link href="https://fonts.googleapis.com/css?family=Roboto&display=swap" rel="stylesheet">

<style>
  body {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  background: #efefef;
  font-family: 'Roboto';
}
body #wrap {
  width: 400px;
  height: 400px;
  display: grid;
  grid-template-columns: repeat(3, 25%);
  grid-template-rows: repeat(3, 25%);
  grid-column-gap: 12.5%;
  grid-row-gap: 12.5%;
}
body #wrap .icon {
  position: relative;
  cursor: pointer;
  box-sizing: border-box;
}
body #wrap .icon:nth-of-type(n + 4) {
  -webkit-transform: translateX(75%);
          transform: translateX(75%);
}
body #wrap .icon .inner {
  position: absolute;
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  left: 0;
  top: 0;
  border: 3px solid #1155cb;
  box-shadow: 0 20px 50px -10px rgba(0, 0, 0, 0);
  background: #fff;
  border-radius: 100%;
  transition: 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.075);
}
body #wrap .icon:before {
  position: absolute;
  color: #c8a977;
  bottom: -25px;
  width: 100%;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 2px;
  font-size: 12px;
  pointer-events: none;
  transition: 0.3s ease-in-out;
}
body #wrap .icon:after {
  content: '';
  position: absolute;
  width: 50%;
  height: 100%;
  left: 25%;
  top: 30px;
  background: linear-gradient(to right, #c8a977, #c8a977);
  background-size: 100% 2px;
  background-repeat: no-repeat;
  -webkit-animation: lineIn1 0.3s ease-in-out 1 forwards;
          animation: lineIn1 0.3s ease-in-out 1 forwards;
}
@-webkit-keyframes lineIn1 {
  from {
    background-position: 0px 100%;
  }
  to {
    background-position: 100px 100%;
  }
}
@keyframes lineIn1 {
  from {
    background-position: 0px 100%;
  }
  to {
    background-position: 100px 100%;
  }
}
body #wrap .icon:hover .inner {
  border-color: #c8a977;
}
body #wrap .icon:hover:after {
  -webkit-animation: lineIn2 0.3s ease-in-out 1 forwards;
          animation: lineIn2 0.3s ease-in-out 1 forwards;
}
@-webkit-keyframes lineIn2 {
  from {
    background-position: -100px 100%;
  }
  to {
    background-position: 0px 100%;
  }
}
@keyframes lineIn2 {
  from {
    background-position: -100px 100%;
  }
  to {
    background-position: 0px 100%;
  }
}
body #wrap .icon:hover:before {
  color: #1155cb;
}
body #wrap .icon svg {
  position: absolute;
  width: 75%;
  left: 12.5%;
  top: 12.5%;
  height: auto;
}
body #wrap .icon:nth-of-type(5):before {
  content: 'teams';
}
body #wrap .icon:nth-of-type(5) svg g, body #wrap .icon:nth-of-type(5) svg path, body #wrap .icon:nth-of-type(5) svg circle {
  stroke-width: 1.5;
}
body #wrap .icon:nth-of-type(5):hover svg g {
  -webkit-animation: clipIn 3s ease-in-out infinite alternate;
          animation: clipIn 3s ease-in-out infinite alternate;
}
@-webkit-keyframes clipIn {
  0% {
    -webkit-clip-path: polygon(-10% 110%, 110% 110%, 110% 110%, -10% 110%);
            clip-path: polygon(-10% 110%, 110% 110%, 110% 110%, -10% 110%);
  }
  15% {
    -webkit-clip-path: polygon(-10% 110%, 110% 110%, 110% 110%, -10% 110%);
            clip-path: polygon(-10% 110%, 110% 110%, 110% 110%, -10% 110%);
  }
  30% {
    -webkit-clip-path: polygon(-10% -10%, 110% -10%, 110% 110%, -10% 110%);
            clip-path: polygon(-10% -10%, 110% -10%, 110% 110%, -10% 110%);
  }
  100% {
    -webkit-clip-path: polygon(-10% -10%, 110% -10%, 110% 110%, -10% 110%);
            clip-path: polygon(-10% -10%, 110% -10%, 110% 110%, -10% 110%);
  }
}
@keyframes clipIn {
  0% {
    -webkit-clip-path: polygon(-10% 110%, 110% 110%, 110% 110%, -10% 110%);
            clip-path: polygon(-10% 110%, 110% 110%, 110% 110%, -10% 110%);
  }
  15% {
    -webkit-clip-path: polygon(-10% 110%, 110% 110%, 110% 110%, -10% 110%);
            clip-path: polygon(-10% 110%, 110% 110%, 110% 110%, -10% 110%);
  }
  30% {
    -webkit-clip-path: polygon(-10% -10%, 110% -10%, 110% 110%, -10% 110%);
            clip-path: polygon(-10% -10%, 110% -10%, 110% 110%, -10% 110%);
  }
  100% {
    -webkit-clip-path: polygon(-10% -10%, 110% -10%, 110% 110%, -10% 110%);
            clip-path: polygon(-10% -10%, 110% -10%, 110% 110%, -10% 110%);
  }
}
body #wrap .icon:nth-of-type(5):hover svg > g > path:nth-of-type(3), body #wrap .icon:nth-of-type(5):hover svg > g > path:nth-of-type(4) {
  stroke-dasharray: 150px;
  -webkit-animation: drawIn3 3s ease-in-out infinite alternate;
          animation: drawIn3 3s ease-in-out infinite alternate;
}
body #wrap .icon:nth-of-type(5):hover svg > g > circle {
  stroke-dasharray: 150px;
  -webkit-animation: drawIn3 3s ease-in-out infinite alternate;
          animation: drawIn3 3s ease-in-out infinite alternate;
}
body #wrap .icon:nth-of-type(5):hover svg > g g:nth-of-type(2) path:nth-of-type(3) {
  stroke-dasharray: 150px;
  -webkit-animation: drawIn3 3s ease-in-out infinite alternate;
          animation: drawIn3 3s ease-in-out infinite alternate;
}
body #wrap .icon:nth-of-type(5):hover svg > g > g g path, body #wrap .icon:nth-of-type(5):hover svg > g > g g circle {
  stroke-dasharray: 150px;
  -webkit-animation: drawIn3 3s ease-in-out infinite alternate;
          animation: drawIn3 3s ease-in-out infinite alternate;
}
body #wrap .icon:nth-of-type(5):hover svg > g > g:first-of-type > path {
  stroke-dasharray: 150px;
  -webkit-animation: drawIn3 3s ease-in-out infinite alternate;
          animation: drawIn3 3s ease-in-out infinite alternate;
}
body #wrap .icon:nth-of-type(5):hover svg > g > g > circle {
  stroke-dasharray: 150px;
  -webkit-animation: drawIn3 3s ease-in-out infinite alternate;
          animation: drawIn3 3s ease-in-out infinite alternate;
}
body #wrap .icon:nth-of-type(5) .inner svg {
  width: 60%;
  top: 20%;
  left: 20%;
}
body #wrap .icon:nth-of-type(4):before {
  content: 'dev portal';
}
body #wrap .icon:nth-of-type(4):hover .inner svg g {
  -webkit-animation: scaleX 3s cubic-bezier(0.175, 0.885, 0.32, 1.075) infinite;
          animation: scaleX 3s cubic-bezier(0.175, 0.885, 0.32, 1.075) infinite;
  -webkit-transform-origin: 15px 50%;
          transform-origin: 15px 50%;
}
body #wrap .icon:nth-of-type(4):hover .inner svg g path:first-of-type {
  -webkit-transform: scaleX(0);
          transform: scaleX(0);
  -webkit-transform-origin: 15px 50%;
          transform-origin: 15px 50%;
  -webkit-animation: scaleX 3s cubic-bezier(0.175, 0.885, 0.32, 1.075) infinite;
          animation: scaleX 3s cubic-bezier(0.175, 0.885, 0.32, 1.075) infinite;
  -webkit-animation-delay: 0.25s;
          animation-delay: 0.25s;
}
@-webkit-keyframes scaleX {
  0% {
    -webkit-transform: scaleX(0);
            transform: scaleX(0);
  }
  10% {
    -webkit-transform: scaleX(0);
            transform: scaleX(0);
  }
  17.5% {
    -webkit-transform: scaleX(1);
            transform: scaleX(1);
  }
  82.5% {
    -webkit-transform: scaleX(1);
            transform: scaleX(1);
  }
  90% {
    -webkit-transform: scaleX(0);
            transform: scaleX(0);
  }
  100% {
    -webkit-transform: scaleX(0);
            transform: scaleX(0);
  }
}
@keyframes scaleX {
  0% {
    -webkit-transform: scaleX(0);
            transform: scaleX(0);
  }
  10% {
    -webkit-transform: scaleX(0);
            transform: scaleX(0);
  }
  17.5% {
    -webkit-transform: scaleX(1);
            transform: scaleX(1);
  }
  82.5% {
    -webkit-transform: scaleX(1);
            transform: scaleX(1);
  }
  90% {
    -webkit-transform: scaleX(0);
            transform: scaleX(0);
  }
  100% {
    -webkit-transform: scaleX(0);
            transform: scaleX(0);
  }
}
body #wrap .icon:nth-of-type(4):hover .inner svg g g path {
  opacity: 1;
  -webkit-clip-path: polygon(0 0, 0 0, 0 100%, 0% 100%);
          clip-path: polygon(0 0, 0 0, 0 100%, 0% 100%);
  -webkit-animation: growIn 1.5s ease-in-out infinite;
          animation: growIn 1.5s ease-in-out infinite;
}
body #wrap .icon:nth-of-type(4):hover .inner svg g g path:nth-of-type(1) {
  -webkit-animation-delay: 0.1666666667s;
          animation-delay: 0.1666666667s;
}
body #wrap .icon:nth-of-type(4):hover .inner svg g g path:nth-of-type(2) {
  -webkit-animation-delay: 0.3333333333s;
          animation-delay: 0.3333333333s;
}
body #wrap .icon:nth-of-type(4):hover .inner svg g g path:nth-of-type(3) {
  -webkit-animation-delay: 0.5s;
          animation-delay: 0.5s;
}
body #wrap .icon:nth-of-type(4):hover .inner svg g g path:nth-of-type(4) {
  -webkit-animation-delay: 0.6666666667s;
          animation-delay: 0.6666666667s;
}
body #wrap .icon:nth-of-type(4):hover .inner svg g g path:nth-of-type(5) {
  -webkit-animation-delay: 0.8333333333s;
          animation-delay: 0.8333333333s;
}
body #wrap .icon:nth-of-type(4):hover .inner svg g g path:nth-of-type(6) {
  -webkit-animation-delay: 1s;
          animation-delay: 1s;
}
body #wrap .icon:nth-of-type(4):hover .inner svg g g path:nth-of-type(7) {
  -webkit-animation-delay: 1.1666666667s;
          animation-delay: 1.1666666667s;
}
body #wrap .icon:nth-of-type(4):hover .inner svg g g path:nth-of-type(8) {
  -webkit-animation-delay: 1.3333333333s;
          animation-delay: 1.3333333333s;
}
body #wrap .icon:nth-of-type(4):hover .inner svg g g path:nth-of-type(9) {
  -webkit-animation-delay: 1.5s;
          animation-delay: 1.5s;
}
body #wrap .icon:nth-of-type(4):hover .inner svg g g path:nth-of-type(10) {
  -webkit-animation-delay: 1.6666666667s;
          animation-delay: 1.6666666667s;
}
body #wrap .icon:nth-of-type(4):hover .inner svg g g path:nth-of-type(11) {
  -webkit-animation-delay: 1.8333333333s;
          animation-delay: 1.8333333333s;
}
body #wrap .icon:nth-of-type(4):hover .inner svg g g path:nth-of-type(12) {
  -webkit-animation-delay: 2s;
          animation-delay: 2s;
}
body #wrap .icon:nth-of-type(4) .inner svg {
  width: 60%;
  top: 20%;
  left: 20%;
}
body #wrap .icon:nth-of-type(3):before {
  content: 'studio';
}
body #wrap .icon:nth-of-type(3):hover .inner svg {
  -webkit-animation: scaleup 2s cubic-bezier(0.175, 0.885, 0.32, 1.275) infinite;
          animation: scaleup 2s cubic-bezier(0.175, 0.885, 0.32, 1.275) infinite;
}
@-webkit-keyframes scaleup {
  0% {
    -webkit-transform: scale(0.75);
            transform: scale(0.75);
  }
  35% {
    -webkit-transform: scale(0.75);
            transform: scale(0.75);
  }
  50% {
    -webkit-transform: scale(1) rotate(-360deg);
            transform: scale(1) rotate(-360deg);
  }
  85% {
    -webkit-transform: scale(1) rotate(-360deg);
            transform: scale(1) rotate(-360deg);
  }
  100% {
    -webkit-transform: scale(0) rotate(-360deg);
            transform: scale(0) rotate(-360deg);
  }
}
@keyframes scaleup {
  0% {
    -webkit-transform: scale(0.75);
            transform: scale(0.75);
  }
  35% {
    -webkit-transform: scale(0.75);
            transform: scale(0.75);
  }
  50% {
    -webkit-transform: scale(1) rotate(-360deg);
            transform: scale(1) rotate(-360deg);
  }
  85% {
    -webkit-transform: scale(1) rotate(-360deg);
            transform: scale(1) rotate(-360deg);
  }
  100% {
    -webkit-transform: scale(0) rotate(-360deg);
            transform: scale(0) rotate(-360deg);
  }
}
body #wrap .icon:nth-of-type(3):hover .inner svg path {
  stroke-dasharray: 150px;
  stroke-dashoffset: 150px;
  -webkit-animation: drawIn2 2s ease-in-out infinite;
          animation: drawIn2 2s ease-in-out infinite;
}
@-webkit-keyframes drawIn2 {
  0% {
    stroke-dashoffset: 150px;
  }
  50% {
    stroke-dashoffset: 0px;
  }
  100% {
    stroke-dashoffset: 0px;
  }
}
@keyframes drawIn2 {
  0% {
    stroke-dashoffset: 150px;
  }
  50% {
    stroke-dashoffset: 0px;
  }
  100% {
    stroke-dashoffset: 0px;
  }
}
@-webkit-keyframes drawIn3 {
  0% {
    stroke-dashoffset: 150px;
  }
  25% {
    stroke-dashoffset: 150px;
  }
  75% {
    stroke-dashoffset: 0px;
  }
  100% {
    stroke-dashoffset: 0px;
  }
}
@keyframes drawIn3 {
  0% {
    stroke-dashoffset: 150px;
  }
  25% {
    stroke-dashoffset: 150px;
  }
  75% {
    stroke-dashoffset: 0px;
  }
  100% {
    stroke-dashoffset: 0px;
  }
}
body #wrap .icon:nth-of-type(3) .inner svg {
  width: 50%;
  left: 24%;
  top: 15%;
}
body #wrap .icon:nth-of-type(3) .inner svg path {
  stroke-width: 2px;
}
body #wrap .icon:nth-of-type(2):before {
  content: 'manager';
}
body #wrap .icon:nth-of-type(2):hover g .line:nth-of-type(1) {
  -webkit-animation-delay: 0.2s;
          animation-delay: 0.2s;
}
body #wrap .icon:nth-of-type(2):hover g .line:nth-of-type(2) {
  -webkit-animation-delay: 0.4s;
          animation-delay: 0.4s;
}
body #wrap .icon:nth-of-type(2):hover g .line:nth-of-type(3) {
  -webkit-animation-delay: 0.6s;
          animation-delay: 0.6s;
}
body #wrap .icon:nth-of-type(2):hover g .line:nth-of-type(4) {
  -webkit-animation-delay: 0.8s;
          animation-delay: 0.8s;
}
body #wrap .icon:nth-of-type(2):hover g .line:nth-of-type(5) {
  -webkit-animation-delay: 1s;
          animation-delay: 1s;
}
body #wrap .icon:nth-of-type(2):hover .line {
  -webkit-clip-path: polygon(0 0, 0 0, 0 100%, 0% 100%);
          clip-path: polygon(0 0, 0 0, 0 100%, 0% 100%);
  -webkit-animation: growIn 1.5s ease-in-out infinite;
          animation: growIn 1.5s ease-in-out infinite;
}
@-webkit-keyframes growIn {
  25% {
    -webkit-clip-path: polygon(0 0, 100% 0, 100% 100%, 0% 100%);
            clip-path: polygon(0 0, 100% 0, 100% 100%, 0% 100%);
  }
  75% {
    -webkit-clip-path: polygon(0 0, 100% 0, 100% 100%, 0% 100%);
            clip-path: polygon(0 0, 100% 0, 100% 100%, 0% 100%);
  }
  100% {
    -webkit-clip-path: polygon(100% 0, 100% 0, 100% 100%, 100% 100%);
            clip-path: polygon(100% 0, 100% 0, 100% 100%, 100% 100%);
 .........完整代码请登录后点击上方下载按钮下载查看

网友评论0