Skip to content
Advertisements

Bootstrap Sidebar Menu

CODEPEN

Bootstrap Sidebar Menu

Github: https://github.com/Furkan-Gulsen/HTML-CSS-JAVASCRIPT/tree/master/Bootstrap%20Sidebar%20Menu


HTML

<section class="sidebar">
        <div class="hamburger_icon">
            <div class="icon"></div>
        </div>
        <div class="sidebar-header px-5">
            <div class="row">
                <img src="https://upload.wikimedia.org/wikipedia/commons/a/ab/Android_O_Preview_Logo.png" alt="">
                <h4 class="d-flex align-items-center px-2">Truecodes</h4>
            </div>
        </div>
        <div class="sidebar-search">
            <div class="input-group">
                <div class="input-group-prepend">
                    <span class="input-group-text purple lighten-3" id="basic-text1"><i class="fas fa-search text-white"
                    aria-hidden="true"></i></span>
                </div>
                <input onkeyup="searchFunction()"  id="search" type="text" class="form-control search-box" placeholder="Search" aria-label="Search">
            </div>
        </div> 

        <div class="sidebar-tag">
            <ul id="tags" class="list-group list-group-flush">
                <li class="list-group-item list-group-item-action d-flex justify-content-between align-items-center">
                    <a href="#" class="nav-link">HTML</a> 
                    <span class="badge badge-warning badge-pill text-light">14</span>
                </li>
                <li class="list-group-item list-group-item-action d-flex justify-content-between align-items-center">
                    <a href="#" class="nav-link">CSS</a> 
                    <span class="badge badge-warning badge-pill text-light">9</span>
                </li>
                <li class="list-group-item list-group-item-action d-flex justify-content-between align-items-center">
                    <a href="#" class="nav-link">JavaScript</a> 
                    <span class="badge badge-warning badge-pill text-light">25</span>
                </li>
                <li class="list-group-item list-group-item-action d-flex justify-content-between align-items-center">
                    <a href="#" class="nav-link">JQuery</a> 
                    <span class="badge badge-warning badge-pill text-light">17</span>
                </li>
                <li class="list-group-item list-group-item-action d-flex justify-content-between align-items-center">
                    <a href="#" class="nav-link">Bootstrap</a> 
                    <span class="badge badge-warning badge-pill text-light">5</span>
                </li>
                <li class="list-group-item list-group-item-action d-flex justify-content-between align-items-center">
                    <a href="#" class="nav-link">Angular</a> 
                    <span class="badge badge-warning badge-pill text-light">10</span>
                </li>
                <li class="list-group-item list-group-item-action d-flex justify-content-between align-items-center">
                    <a href="#" class="nav-link">Node.js</a> 
                    <span class="badge badge-warning badge-pill text-light">14</span>
                </li>
                <li class="list-group-item list-group-item-action d-flex justify-content-between align-items-center">
                    <a href="#" class="nav-link">Mongodb</a> 
                    <span class="badge badge-warning badge-pill text-light">9</span>
                </li>
                <li class="list-group-item list-group-item-action d-flex justify-content-between align-items-center">
                    <a href="#" class="nav-link">Vue.js</a> 
                    <span class="badge badge-warning badge-pill text-light">25</span>
                </li>
                <li class="list-group-item list-group-item-action d-flex justify-content-between align-items-center">
                    <a href="#" class="nav-link">JQuery</a> 
                    <span class="badge badge-warning badge-pill text-light">17</span>
                </li>
                <li class="list-group-item list-group-item-action d-flex justify-content-between align-items-center">
                    <a href="#" class="nav-link">Ember.js</a> 
                    <span class="badge badge-warning badge-pill text-light">5</span>
                </li>
                <li class="list-group-item list-group-item-action d-flex justify-content-between align-items-center">
                    <a href="#" class="nav-link">Meteor</a> 
                    <span class="badge badge-warning badge-pill text-light">10</span>
                </li>
                <li class="list-group-item list-group-item-action d-flex justify-content-between align-items-center">
                    <a href="#" class="nav-link">Polymer</a> 
                    <span class="badge badge-warning badge-pill text-light">5</span>
                </li>
                <li class="list-group-item list-group-item-action d-flex justify-content-between align-items-center">
                    <a href="#" class="nav-link">SQL</a> 
                    <span class="badge badge-warning badge-pill text-light">10</span>
                </li>
                <li class="list-group-item list-group-item-action d-flex justify-content-between align-items-center">
                    <a href="#" class="nav-link">PHP</a> 
                    <span class="badge badge-warning badge-pill text-light">5</span>
                </li>
                <li class="list-group-item list-group-item-action d-flex justify-content-between align-items-center">
                    <a href="#" class="nav-link">mySQL</a> 
                    <span class="badge badge-warning badge-pill text-light">10</span>
                </li>
                <li class="list-group-item list-group-item-action d-flex justify-content-between align-items-center">
                    <a href="#" class="nav-link">Python</a> 
                    <span class="badge badge-warning badge-pill text-light">10</span>
                </li>
            </ul>
        </div>

        <div class="sidebar-menu mt-5">
            <div class="container">
                <ul class="list-group">
                  <li class="list-group-item">HOME</li>
                  <li class="list-group-item">SERVICES</li>
                  <li class="list-group-item dropdown-toggle" id="dropdown_but">ORDERS
                      <ul id="drop_list" class="dropdown-list">
                        <li class="list-group-item">Dropdown 1</li>
                        <li class="list-group-item">Dropdown 2</li>
                        <li class="list-group-item">Dropdown 3</li>
                      </ul>
                  </li>
                  <li class="list-group-item">ABOUT</li>
                </ul>
            </div>
        </div>

CSS(SASS)

@import url('https://fonts.googleapis.com/css?family=Titillium+Web:400,600');
.sidebar{
    position: relative;
    width: 300px;
    background: #8A4C55;
    height: 100vh;
    font-family: 'Titillium Web', sans-serif;
    left: -300px;
    transition: 1s;
    &.scroll{
        left: 0px;
    }

    .hamburger_icon{
        width: 50px;
        height: 50px;
        position: absolute;
        top: 0px;
        right: -50px;
        cursor: pointer;
        .icon{
            position: relative;
            width: 40px;
            height: 7px;
            top: 20px;
            left: 5px;
            background:#8A4C55;
            transition: .4s;
            &:before{
                content: "";
                position: absolute;
                width: 40px;
                height: 7px;
                top: -10px;
                background:#8A4C55;
                transition: .6s;
            }
            &:after{
                content: "";
                position: absolute;
                width: 40px;
                height: 7px;
                top: 10px;
                background:#8A4C55;
                transition: .6s;
            }
        }
        &.active{
            .icon{
                background: none;
                left: -50px;
                &:before{
                    top: 5px;
                    transform: rotate(45deg);
                    background: #ffac1d;
                }
                &:after{
                    top: 5px;
                    transform: rotate(-225deg);
                    background: #ffac1d;
                }  
            }
        }
        
    }

    .sidebar-header{
        margin-bottom: 40px;
        padding-top: 40px !important;

        img{
            width: 60px;
            height: 60px;
            background-size: cover;
        }
        h4{
            color: #f9f9eb;
        }
    }

    .sidebar-search{
            overflow: hidden;
            height: 40px;
        .input-group-prepend{
            span{
                border-radius: 0px !important;
                background-color: #ffac1d;
                border:none;
                box-shadow: inset -5px 0px 3px rgba(0,0,0,.25);
                transition:1s;
                width: 40px;
                height: 40px;
                z-index: 99;
                cursor: pointer;
                .fas{
                    color: #f9f9eb !important;
                    font-size: 20px;
                }
                &:hover{
                    box-shadow: inset -5px 0px 3px rgba(0,0,0,.50);
                }
                &:active{
                    position: absolute;
                    width: 300px;
                }
            }
        }
        .search-box{
            border-radius: 0px !important;
            border-bottom: 1px solid #ffac1d;
            border-top: 1px solid #ffac1d;
            border-left: none;
            border-right: none;
            height: 40px;
            &:focus{
                box-shadow: 0px 0px 10px #262626;
            }
        }
    }

    .sidebar-tag{
        height: 180px;
        overflow: scroll;
        &::-webkit-scrollbar {
            display: none;
        }
        li{
            height: 36px;
            cursor: pointer;
            display: block;
            &.act{
                display: none !important;
            }
        }
        
    }

    .sidebar-menu{
        .list-group{
            
            li{
                background: #D97A7A;
                color: #f9f9eb;
                cursor: pointer;
                transition: .5s;
                &:hover{
                    box-shadow: inset 0px 0px 20px rgba(0,0,0,.3)
                }
                &:active{
                    background: #8A4C55
                }
            }
            #drop_list{
                display: none;

                li{
                    position: relative;
                    left: -61px;
                    top: 15px;
                    width: 144%;
                    text-indent: 20px;
                    background: rgb(169, 95, 95);
                }
            }
        }
    }
}

JavaScript

        $(document).ready(function(){
            $("#dropdown_but").click(function(){
                $("#drop_list").toggle(500)
            })
            $(".hamburger_icon").click(function(){
                $(".hamburger_icon").toggleClass("active");
                $(".sidebar").toggleClass("scroll");
            })
        });


        function searchFunction(){
            let search,tags,filter,tag,a,i;
            search = document.getElementById("search");
            filter = search.value.toUpperCase();
            ul = document.getElementById("tags");
            li = ul.getElementsByTagName("li");

            for(i = 0; i < li.length; i++){
                a = li[i].querySelectorAll("a")[0];
                if( a.innerHTML.toUpperCase().indexOf(filter) > -1){
                    $(li[i]).removeClass("act");
                }
                else{
                    $(li[i]).addClass("act");
                }
            }           
        }
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: