<style>
.uc-menu {
position: fixed;
top: 0;
left: -320px;
transition: left 0.3s;
z-index: 500;
}
.burger-menu {
width: 320px;
height: 100vh;
background-color: blue; /* Цвет фона меню */
}
.overlay {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.5);
display: none;
z-index: 499;
}
.menu-show, .menu-hide {
cursor: pointer;
z-index: 501;
}
.menu-li {
color: black; /* Цвет ссылок */
}
.menu-li:hover {
color: yellow; /* Цвет ссылок при наведении */
}
</style>
<div class='overlay'></div>
<script>
document.addEventListener('DOMContentLoaded', function() {
const showButton = document.querySelector('.menu-show');
const hideButton = document.querySelector('.menu-hide');
const burgerMenu = document.querySelector('.uc-menu');
const overlay = document.querySelector('.overlay');
const menuLiItems = document.querySelectorAll('.menu-li');
showButton.addEventListener('click', function () {
burgerMenu.style.left = '0';
overlay.style.display = 'block';
showButton.style.opacity= '0';
});
hideButton.addEventListener('click', function () {
burgerMenu.style.left = '-320px';
overlay.style.display = 'none';
showButton.style.opacity= '1';
});
overlay.addEventListener('click', function () {
burgerMenu.style.left = '-320px';
overlay.style.display = 'none';
showButton.style.opacity= '1';
});
menuLiItems.forEach(menuLi => {
menuLi.addEventListener('click', function () {
burgerMenu.style.left = '-320px';
overlay.style.display = 'none';
showButton.style.opacity= '1';
});
});
});
</script> <style>
.uc-menu {
position: fixed;
top: 0;
right: -320px; /* Изменение свойства right */
transition: right 0.3s; /* Изменение свойства transition */
z-index: 500;
}
.burger-menu {
width: 320px;
height: 100vh;
background-color: blue; /* Цвет фона меню */
}
</style>
<script>
document.addEventListener('DOMContentLoaded', function() {
const showButton = document.querySelector('.menu-show');
const hideButton = document.querySelector('.menu-hide');
const burgerMenu = document.querySelector('.uc-menu');
const overlay = document.querySelector('.overlay');
const menuLiItems = document.querySelectorAll('.menu-li');
showButton.addEventListener('click', function () {
burgerMenu.style.right = '0';
overlay.style.display = 'block';
showButton.style.opacity= '0';
});
hideButton.addEventListener('click', function () {
burgerMenu.style.right = '-320px';
overlay.style.display = 'none';
showButton.style.opacity= '1';
});
overlay.addEventListener('click', function () {
burgerMenu.style.right = '-320px';
overlay.style.display = 'none';
showButton.style.opacity= '1';
});
menuLiItems.forEach(menuLi => {
menuLi.addEventListener('click', function () {
burgerMenu.style.right = '-320px';
overlay.style.display = 'none';
showButton.style.opacity= '1';
});
});
});
</script>