js+css实现左侧伸缩导航菜单栏效果代码
代码语言:html
所属分类:菜单导航
代码描述:js+css实现左侧伸缩导航菜单栏效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link type="text/css" rel="stylesheet" href="//repo.bfw.wiki/bfwrepo/css/all.6.7.0.css">
<style>
:root {
--bg-black100: #353535;
--bg-black50: #eef0f4;
--bg-black20: #414546;
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body { overflow: auto; }
body.dark {
--bg-black100: #fff;
--bg-black50: #000;
--bg-black20: #eef0f4;
}
.menu {
position: absolute;
width: 60px;
height: 600px;
background-color: var(--bg-black50);
z-index: 2;
top: 0;
bottom: 0;
left: 10px;
margin: auto;
border-radius: .8rem;
transition: .3s ease .15s;
font-family: sans-serif;
}
.menu.open { width: 240px; }
.menu a { text-decoration: none; }
.menu .actionBar {
width: 100%;
height: 10%;
padding: 0.5rem;
overflow: hidden;
}
.menu .actionBar div {
width: 100%;
height: 100%;
display: flex;
align-items: center;
justify-content: space-around;
border-radius: .5rem;
transition: .3s ease;
}
.menu .actionBar div button {
background-color: transparent;
outline: none;
border: none;
border-radius: .5rem;
color: var(--bg-black100);
width: 45px;
height: 45px;
transition: .3s ease;
font-size: 1rem;
cursor: pointer;
}
.menu .actionBar div button:hover { background-color: rgb(132, 0, 255); }
.menu .actionBar div h3 { width: calc(100% - 45px); text-align: center; }
.menu .optionsBar {
overflow: hidden;
display: flex;
width: 100%;
height: 60%;
padding: 0 .5rem;
align-items: center;
flex-direction: column;
}
.menu .optionsBar .menuItem {
width: 100%;
height: 45px;
margin: 0.3rem;
}
.menu .optionsBar .menuItem .menuOption {
font-size: 1rem;
outline: none;
border: none;
background-color: transparent;
width: 100%;
height: 100%;
display: flex;
align-items: center;
justify-content: space-around;
border-radius: .5rem;
transition: .3s ease;
cursor: pointer;
}
.menu .optionsBar .menuItem .menuOption:hover { background-color: rgb(132, 0, 255); }
.menu .optionsBar .menuItem .menuOption i { width: 45px; text-align: center; color: var(--bg-black100); }
.menu .optionsBar .menuItem .menuOption h5 { width: calc(100% - 45px); }
.menuText {
color: var(--bg-black20);
transform: translateX(-250px);
opacity: 0;
transition: transform .3s ease .1s;
}
.menuText.open2 {
opacity: 1;
transform: translateX(0);
}
.menu .menuBreak {
width: 100%;
height: 10px;
display: flex;
align-items: center;
justify-content: center;
}
.menu .menuBreak hr {
width: 50%;
height: 3px;
background-color: var(--bg-black100);
border: none;
border-radius: 5px;
}
.menu .menuUser {
width: 100%;
height: 10px;
padding: 4.5rem 0 3rem 0;
}
.menu .menuUser a {
width: 100%;
height: 100%;
display: flex;
align-items: center;
justify-content: space-between;
text-decoration: none;
padding: 0.5rem;
position: relative;
}
.menu .menuUser a div {
width: 45px;
height: 45px;
position: relative;
border-radius: .5rem;
}
.menu .menuUser a div img {
width: 100%;
height: 100%;
object-fit: c.........完整代码请登录后点击上方下载按钮下载查看
网友评论0