div+css实现漂亮的垂直侧边栏可伸缩菜单效果代码

代码语言:html

所属分类:菜单导航

代码描述:div+css实现漂亮的垂直侧边栏可伸缩菜单效果代码

代码标签: div css 漂亮 垂直 侧边栏 伸缩 菜单

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

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <link type="text/css" rel="stylesheet" href="//repo.bfw.wiki/bfwrepo/css/font-awesome-4.7.0/css/font-awesome.min.css">
<style>


*{
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Poppins', sans-serif;
}

:root {
  --bg: #2f323f;
}

body{
  min-height: 100vh;
  background-color: var(--bg);
}

.navigation{
  position: fixed;
  background-color: #fff;
  inset: 40px 0 40px 20px;
  width: 75px;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: 0.5s;
}

.menuToggle{
  position: absolute;
  top:0;
  left: 0;
  padding: 0 23px;
  width: 100%;
  height: 60px;
  border-bottom: 1px solid rgba(0,0,0,.25);
  display: flex;
  justify-content: flex-start;
  align-items: center;
  cursor: pointer;
}

.menuToggle::before{
  content: '';
  position: absolute;
  width: 30px;
  height: 2px;
  background-color: #333;
  transform: translateY(-8px);
  transition: 0.5s;
}

.menuToggle::after{
  content: '';
  position: absolute;
  width: 30px;
  height: 2px;
  background-color: #333;
  transform: translateY(8px);
  box-shadow: 0 -8px 0 #333;
  transition: 0.5s;
}

.navigation.active{
  width: 250px;
}

.navigation.active .menuToggle::before{
  transform: translateY(0) rotate(45deg);
}

.navigation.active .menuToggle::after{
  transform:translateY(0) rotate(-45deg);
  box-shadow: 0 0 0 #333;
}

.navigation ul{
  display: flex;
  flex-direction: column;
  width: 100%;
}

.navigation ul li{
  list-style: none;
  position: relative;
  width: 100%;
  height: 76px;
  border-radius: 12px;
  border: 8px solid transparent;
  transition: 0.5s;
}

.navigation ul li a{
  position: relative;
  display: flex;
  justify-content: flex-start;
  align-items: center;
  width: 100%;
  text-decoration: none;
  line-height: 60px;
  z-index: 1000;
}

.navigation ul li.active{
  transform: translateX(30px);
  background-color: var(--bg);
}

.navigation ul li .icon{
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 60px;
  height: 60px;
  border-radius: 10px;
  background-color: #fff;
  border: 6px solid transparent;
}

.navigation ul li .fa{
  font-size: 1.75em;
  position: relative;
  z-index: 50;
}

.navigation ul li::before{
  content: '';
  position: absolute;
  top:-28px;
  right: -10px;
  width: 20px;
  height: 20px;
  background: transparent;
  border-bottom-right-radius: 20px;
  box-shadow: 6px 5px 0 5px var(--bg);
  transform: scale(0);
  transform-origin: bottom right;
  transition: 0.5s;
}

.navigation ul li::after{
  content: '';
  position: absolute;
  bottom:-28px;
  right: -10px;
  width: 20px;
  height: 20px;
  background: transparent;
  border-top-right-radius: 20px;
  box-shadow: 6px -5px 0 5px var(--bg);
  transform: scale(0);
  transform-origin: bottom right;
  transition: 0.5s;
}

.navigation ul li.active::before{
  right: 22px;
  transform: scale(1);
}

.navigation ul li.active::after{
  right: 22px;
  transform: scale(1);
}

.navigation ul li.active .icon{
  background-color: var(--clr);
  .........完整代码请登录后点击上方下载按钮下载查看

网友评论0