简体   繁体   English

Bootstrap Side Nav禁用水平滚动

[英]Bootstrap Side Nav disable horizontal scroll

I have a side nav that I plan on using for my site. 我有一个计划用于网站的侧面导航。 However, when I resize the screen to mobile and open the side menu, the scroll wheel becomes visible and am able to scroll of to the side horizontally. 但是,当我调整屏幕大小以移动到并打开侧面菜单时,滚轮变为可见,并且能够水平滚动到侧面。 I want to disable this from happening so that when the side nav is open, horizontal scroll becomes locked/disabled. 我想禁用这种情况,以便在打开侧边导航栏时,水平滚动变得锁定/禁用。 I've been trying to figure out how to disable it but cannot figure out how. 我一直试图找出如何禁用它,但无法找出如何。 Any help would be much appreciated. 任何帮助将非常感激。

I've tried the css width:100%; overflow-x:hidden; 我已经尝试过CSS width:100%; overflow-x:hidden; width:100%; overflow-x:hidden; but that did not work. 但这没有用。

Here is the Codepen 这是Codepen

I would switch to using transform instead: 我将改用使用transform

.body-slide-in {
 tranform: translateX(200px);
}

Transform will move the div visually without altering it's actual position in the DOM. 变换将可视地移动div而不更改其在DOM中的实际位置。 This will be far less likely to cause layout, overflow or position issues. 这将不太可能引起布局,溢出或位置问题。

EDIT-- 编辑 -

However, if you wish to use the overflow option, try adding overflow-x: hidden; 但是,如果您希望使用overflow选项,请尝试添加overflow-x: hidden; to the .container-fluid div directly above the .body-slide-in element. 直接位于.body-slide-in元素上方的.container-fluid div。 It should work. 它应该工作。

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

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