ionicons+css实现左侧垂直侧边栏菜单伸缩明暗切换效果代码

代码语言:html

所属分类:菜单导航

代码描述:ionicons+css实现左侧垂直侧边栏菜单伸缩明暗切换效果代码,支持暗色切换,菜单伸缩。

代码标签: ionicons 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">
        <!-- 引入css文件 -->

        <!-- 引入字体图标文件 -->

        <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/ionicons.esm.js"></script>
  <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/ionicons.7.1.0.js"></script>


        <title>伸缩侧边栏</title>
        <style>

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box
}

li {
    list-style: none
}

body {
    background-color: #e3e9f8;
    width: 100vw;
    height: 100vh;
    display: flex;
    background-color: #e3e9f8
}

.nav {
    flex: 1;
    height: 64px;
    color: #7a7a7a;
    font-size: 36px;
    font-weight: 600;
    padding-left: 100px;
    line-height: 64px
}

.menu {
    position: relative;
    width: 240px;
    display: flex;
    flex-direction: column;
    background-color: #fafafa;
    padding: 10px 14px;
    transition: width .3s ease-in
}

.menu-author {
    display: flex;
    align-items: center;
    max-height: 40px;
    margin-bottom: 30px;
    cursor: pointer
}

.author-text {
    flex: 1;
    display: flex;
    flex-direction: column;
    max-height: 40px;
    font-size: 14px;
    transition: all .4s
}

.author-name {
    font-weight: 600;
    color: #7a7a7a
}

.author-developer {
    color: #9b9b9b
}

.author-img {
    display: flex;
    justify-content: center;
    min-width: 60px
}

.menu-author img {
    width: 40px;
    height: 40px;
    border-radius: 5px
}

.menu-bar {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between
}

#default {
    background-color: #f6f5ff
}

#default input {
    width: 100%;
    border: 0;
    outline: 0;
    background-color: #f6f5ff;
    font-size: 14px;
    font-weight: 600
}

#default:hover ion-icon {
    color: #7b7b7b
}

.menu-bar li {
    border-radius: 4px;
    height: 50px;
    display: flex;
    align-items: center;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 10px
}

.menu-bar li:hover {
    background-color: #695cfe
}

.menu-bar li:hover ion-icon {
    color: #fff
}

.menu-bar li:hover span {
    color: #fff
}

.menu-bar li span {
    color: #7b7b7b;
    cursor: pointer;
    transition: all .3s
}

ion-icon {
    min-width: 60px;
    font-size: 16px;
    color: #7b7b7b
}

.menu-btn {
    position: absolute;
    top: 20px;
    right: -12.5px;
    width: 25px;
    height: 25px;
    background-color: #695cfe;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center
}

.menu-btn .arrow {
    font-size: 20px;
    color: #fff;
    transition: all .3s
}

.on-dark {
    position: relative;
    width: 50px;
    height: 24px;
    margin-left: 15px;
    border-radius: 15px;
    background-color: #ddd;
    display: flex;
    align-items: center
}

.on-dark div {
    position: absolute;
    left: 4px;
    content: '';
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background-color: #fff;
    transition: all .2s ease-in
}

.on-dark.move {
    position: relative;
    width: 50px;
    height: 24px;
    margin-left: 15px;
    border-radius: 15px;
    background-color: #fff;
    display: flex;
    justify-content: center;
    align-items: center
}

.on-dark.move div {
    position: absolute;
    left: 28px;
    content: '';
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background-color: #242526;
    transition: all .2s ease-in
}

.active-rotate {
    transform: rotate(180deg)
}

.menu.shrink {
    width: 88px
}

.hide {
    display: none
}

.dark {
    background-color: #18191a
}

.menu-dark {
    background-color: #242526
}

.menu-bar-dark {
    color: #fff;
    background-color: #3a3b3c!important
}

.menu-bar.hover-dark li:hover {
    background-color: #3a3b3c
}


        </style>
       
    </head>
    <body>
        <!-- 菜单区域 -->
        <div class="menu">
            <!-- 作者信息 -->
            <div class="menu-author">
                <span class="author-img">
                    <img src="//repo.bfw.wiki/bfwrepo/image/60d41f5173b0d.png?x-oss-process=image/auto-orient,1/resize,m_fill,w_100,h_100,/quality,q_90"/>
                </span>
                <div cla.........完整代码请登录后点击上方下载按钮下载查看

网友评论0