svg+js实现图标滑动底部手机导航条菜单效果代码

代码语言:html

所属分类:菜单导航

代码描述:svg+js实现图标滑动底部手机导航条菜单效果代码

代码标签: svg js 图标 滑动 底部 手机 导航条 菜单

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

<!DOCTYPE html>
<html lang="en" >
<head>
  <meta charset="UTF-8">

<style>
    @import url("https://fonts.googleapis.com/css2?family=Lato&display=swap");
html,
body,
* {
  padding: 0;
  margin: 0;
}

body {
  width: 100vw;
  min-height: 100vh;
  background-color: #212526;
  display: grid;
  place-content: center;
}

:root {
  --active-offset: 13px;
}

.sidebar-container {
  width: 300px;
  height: 55px;
  position: relative;
}
.sidebar-container .sidebar-items {
  width: 100%;
  height: 100%;
  background-color: rgba(255, 255, 255, 0.95);
  border-radius: 7px;
  position: absolute;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 0 20px;
  padding-top: 3px;
  box-sizing: border-box;
}

.sidebar-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
}
.sidebar-item .icon {
  width: 22px;
  stroke: #000;
  stroke-width: 1.5px;
  position: absolute;
  z-index: 4;
  bottom: 0;
  transition: bottom 0.4s;
  cursor: pointer;
}
.sidebar-item .title {
  font-family: "Lato", sans-serif;
  font-size: 0.8rem;
  font-weight: bold;
  position: relative;
  top: 30px;
  opacity: 0;
  transition: top 0.4s, opacity 0.4s;
}

.active-circle {
  width: 45px;
  height: 45px;
  background-color: #3ee387;
  position: absolute;
  top: -53%;
  border-radius: 50%;
  z-index: 2;
  border: 5px solid #212526;
  left: var(--active-offset);
  transition: left 0.4s;
}

.sidebar-item.active .icon {
  bottom: 26px;
}
.sidebar-item.active .title {
  top: 10px;
  opacity: 0.9;
}
</style>
</head>
<body>

<div class="sidebar-container">
        <div class="sidebar-items">
            <div class="active-circle"></div>
            <div class="sidebar-item active" data-active-offset="13px" data-active-index="0">
                <svg class="icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"></path><polyline points="9 22 9 12 15 12 15 22"></polyline></svg>
                <span class="title">Home</span>
            </div>

            <div class="sidebar-item" data-active-offset="62px" data-active-index="1">
                <svg class="icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke-linecap="round" stroke-linejoin="round"><path d="M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"></path><circle cx="12" cy="7" r="4"></circle></svg>
                <span class="title">Contacts</span>
            </div>

            <div class="sidebar-item" data-active-offset="121px" data-active-index="2">
                <svg class="icon" xmlns="http://www.w3.org/2000/s.........完整代码请登录后点击上方下载按钮下载查看

网友评论0