Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
528 views
in Technique[技术] by (71.8m points)

html - Transition property works on the burger button but doesn't work on the menu with class "mobile" when hides/shows

I'm experiencing an issue where the transition property works for the burger but it doesn't work for the menu. It hides/shows with no transition effect.

.top-menu .burger-menu {
  width: 35px;
  height: 5px;
  background: var(--text-dark-blue);
  position: absolute;
  top: 50%;
  left: 10px;
  transform: translateY(-50%);
  border-radius: 4px;
  transition: all .2s ease-in-out.2s;
}

.top-menu .burger-menu:before {
  content: '';
  display: block;
  width: 35px;
  height: 5px;
  background: var(--text-dark-blue);
  position: absolute;
  top: -10px;
  border-radius: 4px;
  transition: all .2s ease-in-out.2s;
}

.top-menu .burger-menu:after {
  content: '';
  display: block;
  width: 35px;
  height: 5px;
  background: var(--text-dark-blue);
  position: absolute;
  bottom: -10px;
  border-radius: 4px;
  transition: all .2s ease-in-out.2s;
}

.top-menu .burger-menu.open:before {
  transform: rotate(45deg);
  top: 0;
  transition: all .2s ease-in-out.2s;
}

.top-menu .burger-menu.open:after {
  transform: rotate(-45deg);
  bottom: 0;
  transition: all .2s ease-in-out.2s;
}

.top-menu .burger-menu .mobile {
  display: none;
  transition: all .2s ease-in-out.2s;
}

.top-menu .burger-menu.open {
  background: 0;
  transition: all .2s ease-in-out.2s;
}

.top-menu .burger-menu.open .mobile {
  display: block;
  position: absolute;
  top: 25px;
  left: -63px;
}

.top-menu .burger-menu.open .mobile ul li a {
  background: var(--text-dark-blue);
  color: #fff;
  display: block;
  min-width: 250px;
  font-size: 30px;
  line-height: 35px;
  padding: 10px;
}

.top-menu .burger-menu.open .mobile ul li a:hover {
  background-color: var(--text-light-blue);
  text-decoration: none;
}
<div class="top-menu">
  <a href="#" class="logo">Site Logo</a>
  <div class="burger-menu">
    <div class="mobile">
      <ul>
        <li><a href="#">Home</a></li>
        <li><a href="#">Free</a></li>
        <li><a href="#">About us</a></li>
      </ul>
    </div>
  </div>
</div>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...