gsap+svg实现炫酷古典菜单悬停动画效果代码

代码语言:html

所属分类:菜单导航

代码描述:gsap+svg实现炫酷古典菜单悬停动画效果代码

代码标签: gsap svg 炫酷 古典 菜单 悬停 动画

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

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

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

  
  
<style>
@import url("https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:ital,wght@1,500&display=swap");
html,
body {
  height: 100%;
}

body {
  background-color: #3d3e4a;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
}

.container {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
}

.radio-btn-group {
  margin: 10px;
}

input[type=radio] {
  opacity: 0;
  position: absolute;
}

input[type=radio]:checked + label::before {
  box-shadow: 0 0 25px 2px #244f2e;
}
input[type=radio]:checked + label span {
  color: #fff;
}

input[type=radio]:focus + label::before {
  box-shadow: 0 0 25px 2px #244f2e;
}

label {
  color: #fff;
  cursor: pointer;
  display: flex;
  font-weight: 500;
  font-style: italic;
  align-items: center;
  justify-content: center;
  font-family: "IBM Plex Mono", monospace;
  height: 50px;
  padding: 0 30px;
  position: relative;
}
label::before {
  background-color: #24252c;
  background-image: repeating-linear-gradient(0deg, #181a29, #181a29 1px, #202436 1px, #202436 2px);
  border-radius: 10px;
  box-shadow: 0 0 0 0 #244f2e;
  content: "";
  height: 100%;
  position: absolute;
  left: 0;
  top: 0;
  overflow: hidden;
  transform: skew(-15deg);
  transition: box-shadow 700ms;
  width: 100%;
  z-index: -1;
}
label span {
  transition: color 350ms;
  z-index: 1;
}
label svg {
  border-radius: 10px;
  overflow: hidden;
  position: absolute;
  transform: skew(-15deg);
}
label svg rect {
  fill: #76b3fa;
  shape-rendering: crispEdges;
}
</style>

  
</head>

<body translate="no">
  <div class="container">
  <div class="radio-btn-group">
    <input type="radio" name="stagger-radio-group" value="1" id="input-one" />
    <label for="input-one">
      <span>Option 1</span>
      <svg height="100%" width="100%" xmlns="http://www.w3.org/2000/svg">
        <g class="left">
          <rect x="-100%" y="0" width="100%" height="2" />
          <rect x="-100%" y="2" width="100%" height="2" />
          <rect x="-100%" y="4" width="100%" height="2" />
          <rect x="-100%" y="6" width="100%" height="2" />
          <rect x="-100%" y="8" width="100%" height="2" />
          <rect x="-100%" y="10" width="100%" height="2" />
          <rect x="-100%" y="12" width="100%" height="2" />
          <rect x="-100%" y="14" width="100%" height="2" />
          <rect x="-100%" y="16" width="100%" height="2" />
          <rect x="-100%" y="18" width="100%" height="2" />
          <rect x="-100%" y="20" width="100%" height="2" />
          <rect x="-100%" y="22" width="100%" height="2" />
          <rect x="-100%" y="24" width="100%" height="2" />
          <rect x="-100%" y="26" width="100%" height="2" />
          <rect x="-100%" y="28" width="100%" height="2" />
          <rect x="-100%" y="30" width="100%" height="2" />
          <rect x="-100%" y="32" width="100%" height="2" />
          <rect x="-100%" y="34" width="100%" height="2" />
          <rect x="-100%" y="36" width="100%" height="2" />
          <rect x="-100%" y="38" width="100%" height="2" />
          <rect x="-100%" y="40" width="100%" height="2" />
          <rect x="-100%" y="42" width="100%" height="2" />
          <rect x="-100%" y="44" width="100%" height="2" />
          <rect x="-100%" y="46" width="100%" height="2" />
          <rect x="-100%" y="48" width="100%" height="2" />
        </g>
      </svg>
    </label>
  </div>

  <div class="radio-btn-group">
    <input type="radio" name="stagger-radio-group" value="2" id="input-two" />
    <label for="input-two">
      <span>Option 2</span>
      <svg height="100%" width="100%" xmlns="http://www.w3.org/2000/svg">
        <g class="left">
          <rect x="-100%" y="0" width="100%" height="2" />
          <rect x="-100%" y="2" width="100%" height="2" />
          <rect x="-100%" y="4" width="100%" height="2" />
          <rect x="-100%" y="6" width="100%" height="2" />
          <rect x="-100%" y="8" width="100%" height="2" />
          <rect x="-100%" y="10" width="100%" height="2" />
          <rect x="-100%" y="12" width="100%" height="2" />
          <rect x="-100%" y="14" width="100%" height="2" />
          <rect x="-100%" y="16" width="100%" height="2" />
          <rect x="-100%" y="18" width=".........完整代码请登录后点击上方下载按钮下载查看

网友评论0