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