纯css实现加号弹出导航菜单效果

代码语言:html

所属分类:菜单导航

代码描述:纯css实现加号弹出导航菜单效果

代码标签: 加号 弹出 导航 菜单 效果

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


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

<link rel='stylesheet' href='https://fonts.googleapis.com/css?family=Montserrat&amp;display=swap"rel="stylesheet'>
<style>
:root {
  --icon-size: 28px;
  --background-color: rgb(204, 220, 255);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  width: 100%;
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  background: var(--background-color);
  overflow: hidden;
}

nav {
  min-width: 300px;
  height: 90px;
  border-radius: 30px;
  box-shadow: 0 5px 6px rgba(0, 0, 0, 0.01), 0 12px 10px rgba(0, 0, 0, 0.01), 0 30px 25px rgba(0, 0, 0, 0.012), 0 100px 80px rgba(0, 0, 0, 0.02);
}
nav ul {
  width: 100%;
  height: 100%;
  display: flex;
}
nav ul li {
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  list-style: none;
  background: white;
}
nav ul li.left {
  padding-left: 10px;
  border-top-left-radius: 30px;
  border-bottom-left-radius: 30px;
  border-top-right-radius: 10px;
}
nav ul li.right {
  padding-right: 10px;
  border-top-right-radius: 30px;
  border-bottom-right-radius: 30px;
  border-top-left-radius: 10px;
}
nav .icon {
  height: var(--icon-size);
  width: var(--icon-size);
  cursor: pointer;
}
nav .icon svg {
  height: var(--icon-size);
  width: var(--icon-size);
  fill: var(--background-color);
}
nav button {
  --size: 75px;
  border: none;
  background: none;
  position: relative;
  width: var(--size);
  height: var(--size);
  display: flex;
  margin-bottom: 100px;
}
nav button span {
  width: var(--size);
  height: var(--size);
  border-radius: 50px;
  background: #75a0ff;
  box-shadow: 0 0 0 12px var(--background-color);
  transition: height 200ms ease, margin 200ms ease;
  overflow: hidden;
}
nav button .icon {
  --icon-size: 24px;
  cursor: pointer;
  transition: transform 320ms ease, opacity 200ms ease;
}
nav button .icon svg {
  fill: #fff;
}
nav button .icon.plus {
  width: var(--size);
  height: var(--size);
  display: flex;
  justify-content: center;
  align-items: center;
}
nav button .icons-container {
  width: 100%;
  height: calc(2 * var(--size));
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}
nav button .icons-container .icon {
  background: rgba(204, 220, 255, 0.25);
  width: calc(1.8 * var(--icon-size));
  height: calc(1.8 * var(--icon-size));
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  position: absolute;
  left: 50%;
  top: calc(-25% + var(--index) * 40%);
  transform: translate(-50%, 100%) rotate(-45deg);
  transition: transform 300ms cubic-bezier(0.65, -0.55, 0.25, 1.25), background 150ms ease;
  transition-delay: calc(var(--index) * 55ms);
}
nav button .icons-container .icon:hover {
  background: rgba(204, 220, 255, 0.45);
}
nav button:focus {
  border: none;
  outline: none;
}
nav button:focus span {
  height: calc(2.6 * var(--size));
  margin-top: calc(-1.6 * var(--size));
}
nav button:focus .icon.plus {
  transform: translateY(-50px) rotate(180deg);
  opacity: 0;
}
nav button:focus .icons-container .icon {
  transform: translate(-50%, -50%) rotate(0);
}
nav button::-moz-focus-inner {
  border: none;
}

.support {
  position: absolute;
  right: 10px;
  bottom: 10px;
  padding: 10px;
  display: flex;
}
.support a {
  margin: 0 10px;
  color: #333333;
  font-size: 1.8rem;
  backface-visibility: hidden;
  transition: all 150ms ease;
}
.support a:hover {
  transform: scale(1.1);
}
</style>

</head>
<body translate="no">
<nav>
<ul>
<li class="left">
<div class="icon">
<svg>
<use xlink:href="#home-icon"></use>
</svg>
</div>
</li>
<li class="center">
<button>
<span>
<div class="icon plus">
<svg>
<use xlink:href="#plus-icon"></use>
</svg>
</div>
<div class="icons-container">
<div class="icon" style="--index: 0;">
<svg>
<use xlink:href="#camera-icon"></use>
</svg>
</div>
<div class="icon" style="--index: 1;">
<svg>
<use xlink:href="#video-icon"></use>
</svg>
</div>
<div class="icon" style="--index: 2;">
<svg>
<use xlink:href="#text-icon"></use>
</svg>
</div>
</div>
</span>
</button>
</li>
<li class="right">
<div class="icon">
<svg>
<use xlink:href="#settings-icon"></use>
</svg>
</div>
</li>
</ul>
</nav>
<svg style="display: none">
<symbol id="home-icon" viewBox="0 0 59.465 59.465" xmlns="http://www.w3.org/2000/svg">
<path d="M 56.985661,19.820762 31.645384,1.1013943 C 30.956423,0.65243677 30.492207,0.33684167 29.798775,0.33684167 c -0.692161,0 -1.176379,0.3155951 -1.845341,0.76455263 L 2.6131578,19.822668 C 2.2435816,20.188433 1.9946575,20.659611 1.8955959,21.17143 1.8181259,21.570216 1.7810551,21.975355 1.780024,22.367789 L 1.700022,52.816737.........完整代码请登录后点击上方下载按钮下载查看

网友评论0