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

91
Views
Slide in hamburger menu adds horizontal scrollbar

The result should be a hamburger menu with slides in from the right on clicking the icon.

This is the code for the main menu where I translate it to the right 100% and when I click on the icon it translates back to 0% bringing it on screen

HTML

<div id="mobilenav" class="mobile-nav">
  <div class="mobile-nav-header">
    
    </div>
    <div class="hamburger">
      <button (click)="closeMenu()">
        <img src="../../assets/icons/close-menu.svg" alt="" />
      </button>
    </div>
  </div>
  <ul class="links">
    
  </ul>
  <div class="socials">
    
  </div>
</div>
.mobile-nav {
  height: 100vh;
  top: 0;
  position: absolute;
  transform: translateX(100%);
  right: 0;
  transition: 0.5s;
  background: white;
  z-index: 99;
}

The JS

openMenu() {
    var mobile_menu = document.getElementById('mobilenav');
    mobile_menu!.style.transform = 'translateY(0px)';
    // mobile_menu!.style.display = 'block';
  }
  closeMenu() {
    var mobile_menu = document.getElementById('mobilenav');
    mobile_menu!.style.transform = 'translateX(100%)';
    // mobile_menu!.style.display = 'none';
  }

The issue is that when closed, it is still possible for the user to scroll horizontally to the right. That should not be possible as the menu should be hidden and there should be no possibility to scroll horizontally.

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

0

The simplest way is to replace position: absolute with position: fixed. This fixes the problem but still allows the page to be horizontally scrollable if needed.

Alternatively, you could add

body {
  overflow-x: hidden;
}

to remove the horizontal scrollbar.

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!