@Vova135798

Почему видно меню в неактивном состоянии?

В мобильной версии сайта видно меню, когда оно не открыто. Я поставил z-index меньше, но это не помогло.
https://codepen.io/vladimir2021794/pen/ZErEwxZ
626f831c7ea88966695596.png
  • Вопрос задан
  • 19 просмотров
Решения вопроса 1
Ugolnikovvv
@Ugolnikovvv
Junior Frontend-разработчик
CSS-свойство z-index определяет положение позиционированного элемента и его дочерних элементов или флекс-элементов по оси z.


@import url("https://fonts.googleapis.com/css2?family=Roboto:wght@300&display=swap");
body {
  margin: 0;
}

* {
  font-family: "Roboto", sans-serif;
}
a {
  text-decoration: none;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
}

.header-content {
  position: relative;
  display: flex;
  flex-direction: row;
  height: 80px;
  align-items: center;
  background-color: #fff;
  z-index: 100;
}

.mobilmenu {
  display: none;
}
.header-logo {
  width: 15%;
  font-size: 24px;
}

.header-menu {
  width: 70%;
}

.header-menu ul {
  padding: 0;
  margin: 0;
  text-align: center;
}

.header-menu li {
  display: inline;
  padding: 0 15px;
}

.header-menu a {
  color: #868e96;
  transition: color 0.5s ease;
  font-size: 18px;
}

.header-menu a:hover {
  color: #000;
}

.header-call {
  width: 15%;
}

.header-call a {
  color: #000;
  font-size: 18px;
}

.header-mobil-menu {
  display: none;
}

@media (max-width: 767px) {
  .burger {
    display: block;
    width: 50px;
    height: 50px;
    border: 0;
    background: transparent;
    cursor: pointer;
  }

  .burger__icon {
    display: block;
    position: relative;
    width: 100%;
    height: 5px;
    background: #000;
    transition: background 0s 0.2s;
  }

  .burger__icon:after,
  .burger__icon:before {
    position: absolute;
    background: #000;
    content: "";
    height: 5px;
    width: 100%;
    left: 0;
    top: 10px;
    transition-duration: 0.2s, 0.2s;
    transition-delay: 0.2s, 0s;
    transition-property: top, transform;
  }

  .burger__icon:before {
    top: -10px;
  }

  .burger.active .burger__icon {
    background: transparent;
  }

  .burger.active .burger__icon:after,
  .burger.active .burger__icon:before {
    top: 0;
    transform: rotate(45deg);
    transition-delay: 0s, 0.2s;
  }

  .burger.active .burger__icon:before {
    transform: rotate(-45deg);
  }
  .header-mobil-menu {
    position: relative;
    display: flex;
    width: 50%;
    z-index: 100;
    text-align: left;
    justify-content: flex-end;
    background-color: #fff;
  }
  .header-content {
    padding: 0 10px;
  }
  .header-logo {
    position: relative;
    width: 50%;
    z-index: 100;
    background-color: #fff;
  }

  .header-menu {
    display: none;
  }

  .header-call {
    display: none;
  }
  .mobilmenu {
    display: block;
    position: absolute;
    background-color: #fff;
    width: 100%;
    height: 200px;
    top: -120px;
    transition: top 0.4s ease;
    z-index: 1;
  }
  .mobilmenu.active {
    display: block;
    position: absolute;
    top: 80px;

    top: 80px;
  }
  .mobilmenu a {
    color: #000;
  }
  .mobilmenu li {
    list-style: none;
    padding-bottom: 15px;
  }
}
Ответ написан
Комментировать
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы