div+css实现大气简洁侧边栏图标导航菜单点击效果代码
代码语言:html
所属分类:菜单导航
代码描述:div+css实现大气简洁侧边栏图标导航菜单点击效果代码
代码标签: div css 大气 简洁 侧边栏 图标 导航 菜单 点击
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0" > <style> @import url('https://fonts.googleapis.com/css?family=Poppins:200,300,400,500,600,700,800,900&display=swap'); * { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Poppins', sans-serif; } :root { --clr: #14161e; } body { min-height: 100vh; background: var(--clr); } .sidebar { position: absolute; width: 80px; height: 100vh; background: #fff; transition: 0.5s; padding-left: 10px; overflow: hidden; } .sidebar.active { width: 300px; } .sidebar ul { position: relative; height: 100vh; } .sidebar ul li { position: relative; list-style: none; } .sidebar ul li.active { background: var(--clr); border-top-left-radius: 50px; border-bottom-left-radius: 50px; } .sidebar ul li.active::before { content: ''; position: absolute; top: -20px; right: 0; width: 20px; height: 20px; border-bottom-right-radius: 20px; box-shadow: 5px 5px 0 5px var(--clr); background: transparent; } .sidebar ul li.active::after { content: ''; position: absolute; bottom: -20px; right: 0; width: 20px; height: 20px; border-top-right-radius: 20px; box-shadow: 5px -5px 0 5px var(--clr); background: transparent; } .sidebar ul li.logo { margin-bottom: 50px; } .sidebar ul li.logo .icon { font-size: 2em; color: var(--clr); } .sidebar ul li.logo .text { font-size: 1.2em; font-weight: 500; color: var(--clr); } .sidebar ul li a { position: relative; display: flex; white-space: nowrap; text-decoration: none; } .sidebar ul li a .icon { position: relative; display: flex; justify-content: center; align-items: center; min-width: 60px; padding-left: 10px; height: 70px; font-size: 1.5em; color: #333; transition: 0.5s; } .sidebar ul li a .text { position: relative; height: 70px; display: flex; align-items: center; font-size: 1em; color: #333; padding-left: 15px; text-transform: uppercase; letter-spacing: 0.05em; transition: 0.5s; } .sidebar ul li.active a .icon { color: #fff; } .sidebar ul li.active a .text { color: var(--bg); } .sidebar ul li:hover a .icon, .sidebar ul li:hover a .text { color: var(--bg); } .sidebar ul li.active a .icon::before { content: ''; position: absolute; inset: 5px; width: 60px; background: var(--bg); border-radius: 50%; transition: 0.5s; } .sidebar ul li:hover.active a .icon::before { background: #fff; } .buttom { position: absolute; bottom: 0; width: 100%; } .imgBx { position: relative; width: 40px; height: 40px; border-radius: 50%; overflow: hidden; } .imgBx img { position: absolute; top: 0; left: 0; width: 100%; height: 100%; object-fit: cover; } .menuToggle { position: absolute; top: 20px; right: 20px; width: 50px; height: 50px; background: #31a4ff; z-index: 1000; cursor: pointer; display: flex; justify-content: center; align-items: center; } .menuToggle::before { content: ''; position: absolute; width: 30px; height: 3px; background: #fff; transform: translateY(-9px); transition: 0.5s; box-shadow: 0 9px 0 #fff; } .menuToggle::after { content: ''; position: absolute; width: 30px; height: 3px; background: #fff; transform: translateY(9px); transition: 0.5s; } .menuToggle.active::before { transform: translateY(0px) rotate(45deg); box-shadow: 0 0 0 #fff; } .menuToggle.active::after { transform: translateY(0px) rotate(-45deg); } </style> </head> <body> <div class="menuToggle"></div> <div class="sidebar"> <ul> <li class="logo" style="--bg:#333;" > <a href="#"> <div class.........完整代码请登录后点击上方下载按钮下载查看
网友评论0