├── preview.png ├── assets ├── img │ ├── perfil.png │ ├── sidebar-bg.jpg │ ├── yt-logo.svg │ ├── yt-logo-text.svg │ └── yt-logo-full.svg ├── scss │ ├── styles.scss │ ├── layout │ │ └── _layout.scss │ ├── base │ │ └── _base.scss │ ├── components │ │ ├── _header.scss │ │ ├── _breakpoints.scss │ │ └── _sidebar.scss │ └── config │ │ └── _variables.scss ├── js │ └── main.js └── css │ └── styles.css ├── README.md └── index.html /preview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bedimcode/responsive-sidebar-menu-youtube/HEAD/preview.png -------------------------------------------------------------------------------- /assets/img/perfil.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bedimcode/responsive-sidebar-menu-youtube/HEAD/assets/img/perfil.png -------------------------------------------------------------------------------- /assets/img/sidebar-bg.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bedimcode/responsive-sidebar-menu-youtube/HEAD/assets/img/sidebar-bg.jpg -------------------------------------------------------------------------------- /assets/scss/styles.scss: -------------------------------------------------------------------------------- 1 | @import 'config/variables'; 2 | @import 'base/base'; 3 | @import 'layout/layout'; 4 | @import 'components/header'; 5 | @import 'components/sidebar'; 6 | @import 'components/breakpoints'; 7 | -------------------------------------------------------------------------------- /assets/scss/layout/_layout.scss: -------------------------------------------------------------------------------- 1 | /*=============== LAYOUT ===============*/ 2 | .container{ 3 | margin-inline: 1.5rem; 4 | } 5 | 6 | .main{ 7 | padding-top: 5rem; 8 | } 9 | 10 | .bg-image{ 11 | position: absolute; 12 | left: 0; 13 | top: 0; 14 | width: 100%; 15 | height: 100%; 16 | object-fit: cover; 17 | object-position: center; 18 | z-index: -1; 19 | } 20 | -------------------------------------------------------------------------------- /assets/scss/base/_base.scss: -------------------------------------------------------------------------------- 1 | /*=============== BASE ===============*/ 2 | *{ 3 | box-sizing: border-box; 4 | padding: 0; 5 | margin: 0; 6 | } 7 | 8 | body{ 9 | font-family: var(--body-font); 10 | font-size: var(--normal-font-size); 11 | color: var(--text-color); 12 | } 13 | 14 | a{ 15 | text-decoration: none; 16 | } 17 | 18 | img{ 19 | display: block; 20 | max-width: 100%; 21 | height: auto; 22 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Responsive Sidebar Menu 2 | ## [Watch it on youtube](https://youtu.be/RhT04ifx3vw) 3 | ### Responsive Sidebar Menu 4 | 5 | - Responsive Sidebar Menu Using HTML CSS & JavaScript 6 | - Contains glass effect & gradient borders. 7 | - Developed first with the Mobile First methodology, then for desktop. 8 | - Compatible with all mobile devices and with a beautiful and pleasant user interface. 9 | 10 | 💙 Join the channel to see more videos like this. [Bedimcode](https://www.youtube.com/@Bedimcode) 11 | 12 |  13 | -------------------------------------------------------------------------------- /assets/scss/components/_header.scss: -------------------------------------------------------------------------------- 1 | /*=============== HEADER ===============*/ 2 | .header{ 3 | position: fixed; 4 | top: 0; 5 | left: 0; 6 | width: 100%; 7 | background-color: var(--dark-color-light); 8 | backdrop-filter: blur(16px); 9 | -webkit-backdrop-filter: blur(16px); 10 | z-index: var(--z-fixed); 11 | 12 | &::after{ 13 | content: ''; 14 | position: absolute; 15 | left: 0; 16 | bottom: 0; 17 | width: 100%; 18 | height: 1px; 19 | background: var(--gradient-x); 20 | } 21 | &__container{ 22 | height: var(--header-height); 23 | display: flex; 24 | justify-content: space-between; 25 | align-items: center; 26 | } 27 | &__toggle{ 28 | font-size: 1.25rem; 29 | color: var(--white-color); 30 | cursor: pointer; 31 | } 32 | &__logo{ 33 | width: 70px; 34 | } 35 | } -------------------------------------------------------------------------------- /assets/js/main.js: -------------------------------------------------------------------------------- 1 | /*=============== SHOW SIDEBAR ===============*/ 2 | const showSidebar = (toggleId, sidebarId, mainId) =>{ 3 | const toggle = document.getElementById(toggleId), 4 | sidebar = document.getElementById(sidebarId), 5 | main = document.getElementById(mainId) 6 | 7 | if(toggle && sidebar && main){ 8 | toggle.addEventListener('click', ()=>{ 9 | /* Show sidebar */ 10 | sidebar.classList.toggle('show-sidebar') 11 | /* Add padding main */ 12 | main.classList.toggle('main-pd') 13 | }) 14 | } 15 | } 16 | showSidebar('header-toggle','sidebar', 'main') 17 | 18 | /*=============== LINK ACTIVE ===============*/ 19 | const sidebarLink = document.querySelectorAll('.sidebar__link') 20 | 21 | function linkColor(){ 22 | sidebarLink.forEach(l => l.classList.remove('active-link')) 23 | this.classList.add('active-link') 24 | } 25 | 26 | sidebarLink.forEach(l => l.addEventListener('click', linkColor)) -------------------------------------------------------------------------------- /assets/img/yt-logo.svg: -------------------------------------------------------------------------------- 1 | 17 | -------------------------------------------------------------------------------- /assets/scss/config/_variables.scss: -------------------------------------------------------------------------------- 1 | /*=============== GOOGLE FONTS ===============*/ 2 | @import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;500;600&display=swap'); 3 | 4 | /*=============== VARIABLES CSS ===============*/ 5 | :root{ 6 | --header-height: 3.5rem; 7 | 8 | /*========== Colors ==========*/ 9 | /*Color mode HSL(hue, saturation, lightness)*/ 10 | --white-color: hsl(210, 32%, 99%); 11 | --text-color: hsl(210, 4%, 55%); 12 | --dark-color-light: hsla(210, 4%, 4%, .1); 13 | --white-color-light: hsla(210, 4%, 99%, .1); 14 | --gradient-x: linear-gradient(90deg, 15 | hsla(0, 0%, 0%, 0), 16 | hsl(210, 4%, 64%), 17 | hsla(0, 0%, 0%, 0)); 18 | --gradient-y: linear-gradient(0, 19 | hsla(0, 0%, 0%, 0), 20 | hsl(210, 4%, 64%), 21 | hsla(0, 0%, 0%, 0)); 22 | 23 | /*========== Font and typography ==========*/ 24 | /*.5rem = 8px | 1rem = 16px ...*/ 25 | --body-font: 'Montserrat', sans-serif; 26 | 27 | --normal-font-size: .938rem; 28 | --small-font-size: .813rem; 29 | 30 | // Responsive typography 31 | @media screen and (min-width: 1024px){ 32 | --normal-font-size: 1rem; 33 | --small-font-size: .875rem; 34 | } 35 | 36 | /*========== Font weight ==========*/ 37 | --font-medium: 500; 38 | --font-semi-bold: 600; 39 | 40 | /*========== z index ==========*/ 41 | --z-tooltip: 10; 42 | --z-fixed: 100; 43 | } -------------------------------------------------------------------------------- /assets/scss/components/_breakpoints.scss: -------------------------------------------------------------------------------- 1 | /*=============== BREAKPOINTS ===============*/ 2 | /* For small devices */ 3 | @media screen and (max-width: 300px){ 4 | .sidebar{ 5 | width: 232px; 6 | padding-inline: 1rem; 7 | 8 | &__account{ 9 | flex-direction: column; 10 | row-gap: .5rem; 11 | text-align: center; 12 | 13 | & i{ 14 | margin: 0; 15 | } 16 | } 17 | } 18 | } 19 | 20 | /* For large devices */ 21 | @media screen and (min-width: 1024px){ 22 | .header{ 23 | &__container{ 24 | height: calc(var(--header-height) + 1.5rem); 25 | } 26 | &__toggle{ 27 | font-size: 1.5rem; 28 | } 29 | } 30 | 31 | .sidebar{ 32 | left: 0; 33 | top: calc(var(--header-height) + 1.5rem); 34 | width: 300px; 35 | transition: width .4s; 36 | 37 | &__container{ 38 | padding-bottom: 4rem; 39 | overflow: hidden; 40 | } 41 | &__logo{ 42 | transition: padding .4s; 43 | } 44 | &__link{ 45 | position: relative; 46 | padding-inline: 1.5rem; 47 | column-gap: 2rem; 48 | 49 | & i{ 50 | font-size: 1.5rem; 51 | } 52 | &-name{ 53 | transition: color .4s, opacity .4s; 54 | } 55 | } 56 | &__title{ 57 | position: relative; 58 | 59 | &::after{ 60 | content: ''; 61 | position: absolute; 62 | top: 50%; 63 | left: 0; 64 | width: 100%; 65 | height: 1px; 66 | background: var(--gradient-x); 67 | opacity: 0; 68 | } 69 | } 70 | &__account{ 71 | column-gap: 1rem; 72 | padding-left: .5rem; 73 | margin-top: auto; 74 | } 75 | &__logo-text, 76 | &__title, 77 | &__title::after, 78 | &__title span{ 79 | transition: opacity .4s; 80 | } 81 | &__link-floating{ 82 | display: block; 83 | font-size: 10px; 84 | width: max-content; 85 | margin: 0 auto; 86 | position: absolute; 87 | left: 0; 88 | right: 0; 89 | bottom: 4px; 90 | transition: color .4s, opacity .4s; 91 | opacity: 0; 92 | } 93 | } 94 | 95 | .main{ 96 | padding-left: 300px; 97 | padding-top: 6rem; 98 | transition: padding .4s; 99 | } 100 | 101 | /* Reduce sidebar */ 102 | .show-sidebar{ 103 | width: 120px; 104 | 105 | & .sidebar__logo{ 106 | padding-left: 1rem; 107 | } 108 | & .sidebar__logo-text, 109 | & .sidebar__link-name{ 110 | opacity: 0; 111 | } 112 | & .sidebar__title span{ 113 | opacity: 0; 114 | pointer-events: none; 115 | } 116 | & .sidebar__title::after{ 117 | opacity: 1; 118 | } 119 | & .sidebar__link:hover .sidebar__link-floating{ 120 | opacity: 1; 121 | color: var(--white-color); 122 | } 123 | & .main{ 124 | padding-left: 300px; 125 | } 126 | } 127 | 128 | /* Add padding main */ 129 | .main-pd{ 130 | padding-left: 120px; 131 | } 132 | } 133 | -------------------------------------------------------------------------------- /assets/scss/components/_sidebar.scss: -------------------------------------------------------------------------------- 1 | /*=============== SIDEBAR ===============*/ 2 | .sidebar{ 3 | position: fixed; 4 | left: -100%; 5 | top: var(--header-height); 6 | width: 280px; 7 | height: 100%; 8 | padding: 2rem 1.5rem; 9 | background-color: var(--dark-color-light); 10 | backdrop-filter: blur(16px); 11 | -webkit-backdrop-filter: blur(16px); 12 | z-index: var(--z-fixed); 13 | transition: left .4s; 14 | 15 | &::after{ 16 | content: ''; 17 | position: absolute; 18 | right: 0; 19 | top: 0; 20 | width: 1px; 21 | height: 100%; 22 | background: var(--gradient-y); 23 | } 24 | &__container{ 25 | display: flex; 26 | flex-direction: column; 27 | row-gap: 2rem; 28 | padding-bottom: 3rem; 29 | height: 100%; 30 | } 31 | &__logo{ 32 | display: grid; 33 | grid-template-columns: repeat(2, max-content); 34 | column-gap: .5rem; 35 | 36 | &-img{ 37 | width: 37px; 38 | } 39 | &-text{ 40 | width: 76px; 41 | } 42 | } 43 | &__content{ 44 | position: relative; 45 | overflow: auto; 46 | padding-top: 2rem; 47 | 48 | &::-webkit-scrollbar{ 49 | display: none; 50 | } 51 | &::after{ 52 | content: ''; 53 | position: absolute; 54 | top: 0; 55 | left: 0; 56 | width: 100%; 57 | height: 1px; 58 | background: var(--gradient-x); 59 | } 60 | } 61 | &__list{ 62 | display: flex; 63 | flex-direction: column; 64 | row-gap: .25rem; 65 | } 66 | &__link{ 67 | &-floating{ 68 | display: none; 69 | } 70 | 71 | color: var(--text-color); 72 | display: grid; 73 | grid-template-columns: repeat(2, max-content); 74 | align-items: center; 75 | column-gap: 1.5rem; 76 | padding: 1rem; 77 | border-radius: .25rem; 78 | transition: background .3s; 79 | 80 | & i{ 81 | color: var(--white-color); 82 | font-size: 1.25rem; 83 | } 84 | &-name{ 85 | font-weight: var(--font-medium); 86 | transition: color .4s; 87 | } 88 | &:hover{ 89 | background-color: var(--white-color-light); 90 | backdrop-filter: blur(16px); 91 | -webkit-backdrop-filter: blur(16px); 92 | color: var(--white-color); 93 | } 94 | } 95 | &__title span{ 96 | display: block; 97 | position: relative; 98 | margin-block: 2rem 1.5rem; 99 | text-align: center; 100 | color: var(--white-color); 101 | font-size: var(--normal-font-size); 102 | 103 | &::before, 104 | &::after{ 105 | content: ''; 106 | position: absolute; 107 | top: 50%; 108 | width: 30%; 109 | height: 1px; 110 | } 111 | &::before{ 112 | background: linear-gradient(90deg, 113 | hsla(0, 0%, 0%, 0), 114 | hsl(210, 4%, 64%)); 115 | left: 0; 116 | } 117 | &::after{ 118 | background: linear-gradient(90deg, 119 | hsl(210, 4%, 64%), 120 | hsla(0, 0%, 0%, 0)); 121 | right: 0; 122 | } 123 | } 124 | &__perfil{ 125 | width: 55px; 126 | border-radius: 50%; 127 | border: 2px solid var(--white-color); 128 | } 129 | &__account{ 130 | display: flex; 131 | align-items: center; 132 | column-gap: .5rem; 133 | } 134 | &__name{ 135 | font-size: var(--normal-font-size); 136 | color: var(--white-color); 137 | margin-bottom: .25rem; 138 | } 139 | &__email{ 140 | font-size: var(--small-font-size); 141 | font-weight: var(--font-medium); 142 | } 143 | &__account i{ 144 | color: var(--white-color); 145 | font-size: 1.5rem; 146 | margin-left: auto; 147 | cursor: pointer; 148 | } 149 | } 150 | 151 | /* Show sidebar */ 152 | .show-sidebar{ 153 | left: 0; 154 | } 155 | 156 | /* Active link */ 157 | .active-link{ 158 | background-color: var(--white-color-light); 159 | backdrop-filter: blur(16px); 160 | -webkit-backdrop-filter: blur(16px); 161 | 162 | & span{ 163 | color: var(--white-color); 164 | } 165 | } -------------------------------------------------------------------------------- /assets/img/yt-logo-text.svg: -------------------------------------------------------------------------------- 1 | 11 | -------------------------------------------------------------------------------- /assets/img/yt-logo-full.svg: -------------------------------------------------------------------------------- 1 | 23 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 |
18 |
19 |
20 |