Не показываются дроп-дауны на мобильном устройстве
На десктопе все отлично, и даже через гугл адаптацию для мобильных устройств все проходит нормально, но как я начинаю выкладывать это на гит пейдж - так сразу на моем айфон 14 про ничего не видно при нажатии на главные кнопки (дроп-даунов нет)
const toggleMenu = () => {
const body = document.body;
body.classList.toggle("open");
// Проверка, открыто ли меню
if (body.classList.contains("open")) {
// Заблокировать прокрутку страницы
body.style.overflow = "hidden";
} else {
// Разблокировать прокрутку страницы
body.style.overflow = "";
}
};
.navbar,
.navbar-burger,
.menu {
position: fixed;
}
.navbar {
z-index: 1501;
top: 0;
left: 0;
display: flex;
align-items: center;
justify-content: space-between;
width: 100%;
height: 72px;
padding-left: 25px;
}
.navbar-burger {
z-index: 1501;
top: 0;
left: 0;
display: grid;
place-items: center;
width: 88px;
height: 150px;
background-image: url("./assets/menu.svg");
background-repeat: no-repeat;
filter: brightness(70%);
background-position: center;
transition: filter 0.3s;
}
.navbar-burger:hover {
filter: brightness(100%);
}
body.open .navbar-burger {
background-image: url("./assets/close.svg");
}
.menu {
z-index: 1200;
top: 0;
left: 0;
display: grid;
align-items: center;
justify-content: flex-start;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.959);
opacity: 0;
overflow: hidden;
visibility: hidden;
transition: 0.5s;
}
body.open .menu {
opacity: 1;
visibility: visible;
}
.menu nav:hover a {
opacity: 0.25;
}
.menu nav:hover .dropbtn {
opacity: 0.25;
}
.menu nav .dropbtn:hover {
opacity: 1;
}
.menu nav a:hover {
opacity: 1;
}
.menu nav {
display: flex;
flex-direction: column;
justify-content: flex-start;
align-items: flex-start;
}
.menu .dropdown-content {
display: none;
position: absolute;
min-width: 160px;
z-index: 1;
left: 280px;
/* Установите фиксированное расстояние здесь */
top: 50%;
/* Выравнивание по середине кнопки */
transform: translateY(-50%);
/* Смещение вверх на половину высоты элемента */
}
.dropdown a {
position: relative;
color: #f9f9f9;
font-size: 32px;
padding: 20px 0;
align-items: flex-start;
width: 300px;
text-decoration: none;
transition: 0.4s;
}
.menu .dropbtn::after {
content: "";
position: absolute;
left: 0;
bottom: 10px;
width: 100%;
height: 2px;
border-radius: 2px;
background: #f7f7f7;
transform: scaleX(0);
transform-origin: 50% 50%;
transition: 0.3s;
}
.menu .dropbtn:hover::after {
transform: scaleX(1);
}
body.open .menu .dropbtn {
animation: appear 0.3s backwards;
}
@keyframes appear {
0% {
opacity: 0;
translate: 0 50px;
}
100% {
opacity: 1;
}
}
.dropdown {
position: relative;
display: block;
}
.dropdown-content {
display: none;
position: absolute;
min-width: 160px;
z-index: 1;
left: 120%;
/* Позиционирование выпадающего меню справа */
top: 50%;
/* Выравнивание по середине кнопки */
transform: translateY(-50%);
/* Смещение вверх на половину высоты элемента */
}
.dropdown-content a {
color: white;
/* Установи цвет текста на белый */
padding: 12px 16px;
text-decoration: none;
display: block;
animation: appear 0.3s backwards;
margin-left: 14vw;
}
.dropdown .dropbtn:focus+.dropdown-content {
display: block;
}
/* Добавьте стили для кнопки */
.dropbtn {
position: relative;
background-color: transparent;
color: white;
/* Установите цвет текста на белый */
padding: 16px;
font-size: 40px;
border: none;
cursor: pointer;
text-decoration: none;
display: flex;
align-items: center;
margin-left: 4em;
}
.dropbtn:hover,
.dropbtn:focus {
background-color: transparent;
}
.dropdown .fa-chevron-right {
font-size: 15px;
margin-left: 25px;
/* Регулируйте это значение для изменения расстояния стрелки от текста кнопки */
transition: all 0.3s ease;
}
.dropdown:hover .fa-chevron-right,
.dropdown .dropbtn:focus .fa-chevron-right {
transform: translateX(5px);
}
@media screen and (max-width: 400px) {
.dropbtn {
font-size: 18px;
margin-left: 2px;
}
.dropdown-content a {
font-size: 16px;
margin-left: -200px;
}
}
@media (min-width: 401px) and (max-width: 700px) {
.dropdown-content a {
font-size: 22px;
margin-left: -100px;
}
.dropbtn {
font-size: 22px;
margin-left: 20px;
}
}
@media screen and (min-width: 701px) and (max-width: 1200px) {
.dropbtn {
font-size: 24px;
}
.dropdown-content a {
font-size: 24px;
margin-left: 10px;
}
.menu {
z-index: 1200;
top: 0;
left: 0;
display: grid;
place-items: flex start;
justify-content: flex-start;
width: 100%;
height: 100%;
/* Сохраняет высоту */
background: rgba(0, 0, 0, 0.959);
opacity: 0;
overflow: hidden;
visibility: hidden;
transition: 0.5s;
}
.dropbtn {
margin-left: 50px;
}
}
<button class="navbar-burger" onclick="toggleMenu()"></button>
<div class="menu">
<nav>
<div class="dropdown">
<button class="dropbtn" style="animation-delay: 0.1s">О нас <i class="fa-solid fa-chevron-right"></i></button>
<div class="dropdown-content">
<a href="#">Подменю 1</a>
<a href="#">Подменю 2</a>
<a href="#">Подменю 3</a>
<a href="#">Подменю 4</a>
</div>
</div>
<div class="dropdown">
<button class="dropbtn" style="animation-delay: 0.2s">Грант <i class="fa-solid fa-chevron-right"></i></button>
<div class="dropdown-content">
<a href="#">Подменю 1</a>
<a href="#">Подменю 2</a>
<a href="#">Подменю 3</a>
<a href="#">Подменю 4</a>
</div>
</div>
<div class="dropdown">
<button class="dropbtn" style="animation-delay: 0.2s">Поступление <i class="fa-solid fa-chevron-right"></i></button>
<div class="dropdown-content">
<a href="#">Подменю 1</a>
<a href="#">Подменю 2</a>
<a href="#">Подменю 3</a>
<a href="#">Подменю 4</a>
</div>
</div>
<a href="#" class="dropbtn" style="animation-delay: 0.4s">Новости</a>
<a href="contact.html" class="dropbtn" style="animation-delay: 0.5s">Контакты</a>
<div class="dropdown">
<button class="dropbtn" style="animation-delay: 0.5s">Родителям <i class="fa-solid fa-chevron-right"></i></button>
<div class="dropdown-content">
<a href="#">Подменю 1</a>
<a href="#">Подменю 2</a>
<a href="#">Подменю 3</a>
<a href="#">Подменю 4</a>
</div>
</div>
</nav>
</div>