seredniy
9/12/2016 - 4:18 PM

Адаптивное меню

Адаптивное меню

// Сформируем мобильное меню
    $('.menu li').each(function(index, el) {$('#slide-side').append($(this).html());});

    // Обработаем клики и покажем или скроем меню
     $('.open-menu').click(function(event) {$('#slide-side').toggleClass('lefter'); $('.overlay').toggleClass('show')});
     $('.overlay').click(function(event) {$('#slide-side').toggleClass('lefter'); $('.overlay').toggleClass('show')});
     
     
     
    // Вставить где-нибудь на странице
    <div id="slide-side"><div class="open-menu"></div></div>
	  <div class="overlay"></div>	
	  
	   // Кнопка открытия
    <div class="open-menu"></div>
    
    
    
    // Стили
    
.open-menu {
	height: 100%;
	position: absolute;
	right: 0;
	top: 0;
	background: #2A9F39 url(data:image/svg+xml;utf8;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iaXNvLTg4NTktMSI/Pgo8IS0tIEdlbmVyYXRvcjogQWRvYmUgSWxsdXN0cmF0b3IgMTkuMC4wLCBTVkcgRXhwb3J0IFBsdWctSW4gLiBTVkcgVmVyc2lvbjogNi4wMCBCdWlsZCAwKSAgLS0+CjxzdmcgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgdmVyc2lvbj0iMS4xIiBpZD0iTGF5ZXJfMSIgeD0iMHB4IiB5PSIwcHgiIHZpZXdCb3g9IjAgMCAzMDIgMzAyIiBzdHlsZT0iZW5hYmxlLWJhY2tncm91bmQ6bmV3IDAgMCAzMDIgMzAyOyIgeG1sOnNwYWNlPSJwcmVzZXJ2ZSIgd2lkdGg9IjI0cHgiIGhlaWdodD0iMjRweCI+CjxnPgoJPHJlY3QgeT0iMzYiIHdpZHRoPSIzMDIiIGhlaWdodD0iMzAiIGZpbGw9IiNGRkZGRkYiLz4KCTxyZWN0IHk9IjIzNiIgd2lkdGg9IjMwMiIgaGVpZ2h0PSIzMCIgZmlsbD0iI0ZGRkZGRiIvPgoJPHJlY3QgeT0iMTM2IiB3aWR0aD0iMzAyIiBoZWlnaHQ9IjMwIiBmaWxsPSIjRkZGRkZGIi8+CjwvZz4KPGc+CjwvZz4KPGc+CjwvZz4KPGc+CjwvZz4KPGc+CjwvZz4KPGc+CjwvZz4KPGc+CjwvZz4KPGc+CjwvZz4KPGc+CjwvZz4KPGc+CjwvZz4KPGc+CjwvZz4KPGc+CjwvZz4KPGc+CjwvZz4KPGc+CjwvZz4KPGc+CjwvZz4KPGc+CjwvZz4KPC9zdmc+Cg==) center center no-repeat;
	width: 50px;
	color: #fff;
	cursor: pointer;
	display: none;
}

#slide-side {

       display: block;
    position: fixed;
    top: 0;
    left: -260px;
    height: 100%;
    z-index: 999999;
    padding: 20px;
    width: 260px;
    overflow-x: hidden;
    overflow-y: auto;
    font-size: 15px;
    background: #2a9f39;
    color: #fff;
    box-shadow: 0 0 5px 5px #2a9f39 inset;
    transition: left 0.3s ease;
    box-sizing: border-box;
}

#slide-side a{
    text-decoration: none;
    color: #fff;
    display: block;
    font-size: 110%;
    border-bottom: 1px dashed #585656;
    text-align: center;
    padding-bottom: 5px;
    padding-top: 5px;

}

#slide-side .open-menu{
    position: absolute;
    display: block; 
    right: 15px;
    top: 15px;
    width: 24px;
    height: 24px;
    cursor: pointer;
    background: url(data:image/svg+xml;utf8;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iaXNvLTg4NTktMSI/Pgo8IS0tIEdlbmVyYXRvcjogQWRvYmUgSWxsdXN0cmF0b3IgMTkuMS4wLCBTVkcgRXhwb3J0IFBsdWctSW4gLiBTVkcgVmVyc2lvbjogNi4wMCBCdWlsZCAwKSAgLS0+CjxzdmcgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgdmVyc2lvbj0iMS4xIiBpZD0iQ2FwYV8xIiB4PSIwcHgiIHk9IjBweCIgdm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w5LjUtNGM1LjMtNS4zLDUuMy0xMy44LDAtMTkuMWwtODUuNC04NS42bDg1LjYtODUuNkMzNDcuNiwxNDYuNywzNDcuNiwxMzguMiwzNDIuMywxMzIuOXoiIGZpbGw9IiNGRkZGRkYiLz4KCTwvZz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8L3N2Zz4K) center center no-repeat;
}

.overlay {
  width: 100%;
  height: 100%;
  position: fixed;
  background: rgba(0,0,0,.8);
  z-index: 99;
  top: 0;
  left: 0;
  display: none;
}

.show {
  display: block!important;
}

.lefter {
left: 0!important;
}