简体   繁体   English

如何防止我的网站汉堡菜单让人们水平滚动

[英]How do I prevent my websites hamburger menu from letting people scroll horizontally

I wanted to know how I would go about preventing people on mobile from swiping sideways after they open and close my hamburger menu.我想知道如何防止移动设备上的人在打开和关闭我的汉堡菜单后侧向滑动。 It works fine before they open it but after it breaks and next time it closed they can scroll sideways.在他们打开它之前它工作正常,但在它破裂之后,下次它关闭时,他们可以横向滚动。 I've tried the things suggested on other questions to no avail.我已经尝试了其他问题上建议的事情,但无济于事。 It's not a very big site yet so there isn't much there.这不是一个很大的网站,所以那里没有太多。

html, body {
    max-width: 100%;
    overflow-x: hidden;
}

Website: mostwantedrbx.github.io网址:mostwantedrbx.github.io

Repo: https://github.com/MostwantedRBX/MostwantedRBX.github.io回购: https://github.com/MostwantedRBX/MostwantedRBX.github.io

this might help可能会有所帮助

body {
    overflow-x: hidden !important;
}
.container {
    max-width: 100% !important;
    overflow-x: hidden !important;
}

Give the.nav-links a position of fixed instead of absolute.给.nav-links 一个 position 固定而不是绝对。

@media screen and (max-width: 788px) {
.nav-links {
    position: fixed; /* instead of absolute */ 
    right: 0px;
    height: 92vh;
    top: 8vh;
    background-color: cornflowerblue;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 30%;
    transform: translateX(100%);
    transition: transform 0.5s ease-in;
}

} }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM