-5

When I want to click the icon on a phone to open the menu I want there to be a transition. This is the code for responsive devices:

@media screen and (min-width: 800px) {
    nav {
      height: 80px;
      flex-direction: row;
    }
  .logo {
      padding-left: 50px;
      margin: 0;
      width: 20%;

    }
  ul {
      display: flex;
      justify-content: flex-end;
      width: 80%;
      flex-direction: row;
    }
  ul li {
      display: inline-block;
      margin: 0 70px 0 0;
      text-align: left;
      border-bottom-style: none;
      padding: 0;
    }
  span.nav-toggle {
      display: none;
    }

    


   
  }

I was expecting nothing because I did not know how to do that. I tried many things but I don't know why it didn't work.

5
  • 2
    You haven't added any transition statements to your CSS Commented Sep 29, 2023 at 21:59
  • Use a JavaScript click handler that adds a class to the menu, and use transition in the style of that class. Commented Sep 29, 2023 at 22:03
  • 1
    Does this answer your question? Adding transition effect to my css Commented Sep 29, 2023 at 22:19
  • Please see How to Ask and take the tour. Your post needs improvement. Commented Sep 29, 2023 at 22:25
  • Can you add your html so I can view the code? Commented Sep 29, 2023 at 22:25

1 Answer 1

0

Hi in your CSS ist a little mistake, you cant give a transition to disply propperties. display: none/block, flex etc. are instand. If you want to build a Navi with transition you should use the height, thats the simplest way.

.navNormal{
      width: 15rem;
      height: 0;
}
.navTransition{
      height: 10rem;
      line-height: 4rem;
      transition:height 0.3s ease-in-out;
      transition-delay: 0.1s;
}

To trigger the animation you can use a Checkbox if you want to use CSS only. Otherwise you can use the onClick/onclick Attibute, an addEventListener (JS without Framework) or command classList.toggle(navTransition)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.