svg+css实现左侧垂直图标菜单伸缩堆叠操作效果代码

代码语言:html

所属分类:菜单导航

代码描述:svg+css实现左侧垂直图标菜单伸缩堆叠操作效果代码

代码标签: svg css 左侧 垂直 图标 菜单 伸缩 堆叠 操作

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

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

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

  
  
  
<style>
body {
  background: #f7f7f7;
}

svg {
  display: inline-block;
  width: 32px;
}

.main {
  background: white;
  position: absolute;
  left: 68px;
  top: 8px;
  right: 8px;
  bottom: 8px;
  border-radius: 8px;
  filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.15));
}

.stack {
  position: relative;
  display: flex;
  flex-direction: column-reverse;
  justify-content: center;
  align-items: center;
  width: 32px;
  transition: all 0.2s;
  filter: drop-shadow(0px 1px 1px rgba(0, 0, 0, 0.2));
  position: absolute;
  bottom: 8px;
  left: 8px;
  background: #ededed;
  padding: 8px 10px 4px 10px;
  border-radius: 12px;
  cursor: pointer;
}

svg {
  height: 32px;
  width: 32px;
  border-radius: 4px;
  background-size: cover;
  overflow: hidden;
  position: relative;
  margin-bottom: 4px;
  transition: all 0.15s;
  transform-origin: 50% 50%;
}

svg:nth-child(2) {
  z-index: 3;
}

svg:nth-child(3) {
  z-index: 2;
}

svg:nth-child(4) {
  z-index: 1;
}

.icon-add {
  width: 12px;
  height: 12px;
}

.icon-chevron {
  width: 6px;
  height: 7px;
}

.stack.closed {
  padding-top: 0;
}
.stack.closed svg {
  transform: scale(0%) translate(0px);
  height: 0;
  opacity: 0;
}
.stack.closed svg:nth-child(n+4) {
  margin-bottom: 1px;
}
.stack.closed svg:nth-child(1) {
  opacity: 1;
  width: 6px;
  height: 7px;
  transform: scale(100%) translate(0px) rotate(-180deg);
}
.stack.closed svg:nth-child(2) {
  transform: scale(100%) translate(0px);
  opacity: 1;
  width: 32px;
  height: 32px;
}
.stack.closed svg:nth-child(3) {
  transform: scale(83.3333%) translateY(0px);
  opacity: 0.8;
  width: 32px;
  height: 32px;
  margin-bottom: -26px;
}
.stack.closed svg:nth-child(4) {
  transform: scale(66.6667%) translateY(0px);
  opacity: 0.6;
  width: 32px;
  height: 32px;
  margin-bottom: -26px;
}

.stack.closed:hover {
  padding-top: 0;
}
.stack.closed:hover svg:nth-child(3) {
  transform: scale(83.3333%) translateY(-2px);
  opacity: 1;
}
.stack.closed:hover svg:nth-child(4) {
  transform: scale(66.6667%) translateY(-2px);
  opacity: 1;
}
</style>


  
  
</head>

<body translate="no">
  <div class="stack">
  <svg width="6" height="7" viewBox="0 0 6 7" fill="none" xmlns="http://www.w3.org/2000/svg"
       class="icon-chevron">
<g clip-path="url(#clip0_3_960)">
<path d="M0.0385628 2.09652C0.0385628 1.90804 0.112293 1.73129 0.246573 1.59847C0.379873 1.46712 0.556143 1.39535 0.743153 1.39681C0.930162 1.39827 1.10545 1.47201 1.23631 1.60482L2.99998 3.39046L4.749 1.61946C4.88035 1.48665 5.05564 1.41243 5.24265 1.41145C5.42966 1.40999 5.60593 1.48176 5.73874 1.61311C5.87302 1.74592 5.94724 1.92268 5.94724 2.11165C5.94724 2.29671 5.87546 2.47151 5.74509 2.60335L3.49802 4.87825C3.35837 5.01595 3.1821 5.08772 2.99509 5.08626C2.80808 5.0848 2.63279 5.01106 2.50193 4.87825L0.240213 2.5887C0.110333 2.45686 0.0385628 2.28207 0.0385628 2.09652Z" fill="#292929"/>
</g>
<defs>
<clipPath id="clip0_3_960">
<rect width="6" height="6" fill="white" transform="matrix(0 1 -1 0 5.99999 0.111145)"/>
</clipPath>
</defs>
</svg>

<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 56 54"><g clip-path="url(#a)"><mask id="b" width="56" height="55" x="0" y="-1" maskUnits="userSpaceOnUse" style="mask-type:luminance"><path fill="#fff" d="M9.91-.0352h36.18c5.473 0 9.91 4.437 9.91 9.91v34.18c0 5.473-4.437 9.91-9.91 9.91H9.91c-5.473 0-9.91-4.437-9.91-9.91v-34.18c0-5.473 4.437-9.91 9.91-9.91Z"/></mask><g mask="url(#b)"><circle cx="27.8782" cy="19.8778" r="23.1272" fill="url(#c)" transform="rotate(18 27.8782 19.8778)"/><circle cx="-.1152" cy="29.3833" r="17.6449" fill="url(#d)" transform="rotate(18 -.1152 29.3833)"/><circle cx="49.3976" cy="3.8978" r="39.8261" fill="url(#e)" transform="rotate(18 49.3976 3.8978)"/><circle cx="22.6758" cy="-4.825" r="29.2809" fill="url(#f)" transform="rotate(18 22.6758 -4.825)"/><circle cx="3.8783" cy="53.8777" r="27.2614" fill="url(#g)" transform="rotate(18 3.8783 53.8777)"/><circle cx="9.3348" cy="39.8338" r="20.4621" fill="url(#h)" transform="rotate(18 9.3348 39.8338)"/><circle cx="5.8782" cy="7.8782" r="29.2809" fill="url(#i)" transform="rotate(18 5.8782 7.8782)"/><circle cx="54.4761" cy="59.4764" r="40.1243" fill="url(#j)" transform="rotate(18 54.4761 59.4764)"/><circle cx="26.195" cy="52.1966" r="15.4931" fill="url(#k)" transform="rotate(18 26.195 52.1966)"/><circle cx="37.8976" cy="34.8964" r="24.091" fill="url(#l)" transform="rotate(18 37.8976 34.8964)"/><circle cx="16.6436" cy="48.9185" r="13.4362" fill="url(#m)" fill-opacity=".4" transform="rotate(18 16.6436 48.9185)"/><circle cx="40.7751" cy="36.7752" r="13.6698" fill="url(#n)" transform="rotate(18 40.7751 36.7752)"/><circle cx="22.6758" cy="-4.825" r="29.2809" fill="url(#o)" transform="rotate(18 22.6758 -4.825)"/><circle cx="54.2182" cy="19.7185" r="12.0647" fill="url(#p)" transform="rotate(18 54.2182 19.7185)"/><circle cx="53.3417" cy="33.8431" r="16.8469" fill="url(#q)" transform="rotate(18 53.3417 33.8431)"/><ellipse cx="17.3573" cy="23.7463" fill="url(#r)" rx="13.9473" ry="6.7788" transform="rotate(18 17.3573 23.7463)"/><ellipse cx="5.1096" cy="13.2108" fill="url(#s)" rx="11.9252" ry="8.973" transform="rotate(18 5.1096 13.2108)"/><ellipse cx="6.1096" cy="6.2108" fill="url(#t)" rx="11.9252" ry="8.973" transform="rotate(18 6.1096 6.2108)"/><circle cx="43.1066" cy="31.1065" r="12.7884" fill="url(#u)" fill-opacity=".4" transform="rotate(18 43.1066 31.1065)"/><circle cx="4.9211" cy="49.9219" r="16.0318" fill="url(#v)" transform="rotate(18 4.9211 49.9219)"/></g><path fill="#fff" d="M43.589 16.5698C40.8653 13.6231 37.1356 12 33.0869 12c-3.8842 0-7.8348 1.677-10.3618 4.3882a12.3748 12.3748 0 0 0-1.3951-.079C13.71.........完整代码请登录后点击上方下载按钮下载查看

网友评论0