Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

146
Views
How do I slide down a mobile menu with height 100vh?

I have the following code in svelte.

When I click the burger (css omitted) it opens the navigation container.

I want the container to slide down in .3s. How do I do that?

I tried a couple things but alas, no difference.

let open = false;

function setBurgerOpen() {
  open = !open;
}
.menu-mobile-content.open {
  height: 100vh;
}
<div class="navbar-mobile">
  <div class="logo">LOGO</div>
  <div class="menu-btn" on:click={setBurgerOpen} class:open={open}>
    <div class="menu-btn-burger"></div>
  </div>
  <div class="menu-mobile-content" class:open={open}>
    <ul>...</ul>
  </div>
</div>

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Use this code.
This code will translate your menu down.

.menu-mobile-content {
    height: 100vh;
    transform: translateY(-100%);
    transition: all .3s ease;
}
.menu-mobile-content.open {
    transform: translateY(0);
}
about 4 years ago · Juan Pablo Isaza Report

0

The Svelte "way" would be to use an {#if ...} block and transitions instead of manipulating styles:

<script>
  import { slide } from 'svelte/transition'
  import { cubicInOut } from 'svelte/easing'

  let open = false;

  function setBurgerOpen() {
    open = !open;
  }
</script>

<style>
  .menu-btn {
    cursor: pointer;
  }
  .menu-mobile-content {
    height: 100vh;
    background-color: pink;
  }
</style>

<div class="navbar-mobile">
  <div class="logo">LOGO</div>
  <div class="menu-btn" on:click={setBurgerOpen}>
    <div class="menu-btn-burger">{open ? "hide" : "show"}</div>
  </div>
  {#if open}
    <div
      transition:slide="{{delay: 250, duration: 300, easing: cubicInOut }}"
      class="menu-mobile-content"
    >
      content
    </div>
  {/if}
</div>

See this demo REPL using the code above.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!