简体   繁体   English

禁用水平滚动

[英]Disable horizontal scrolling

I am looking for a method/trick to DISABLE (not just hide) a horizontal scroll bar. 我正在寻找一种禁用水平滚动条(不只是隐藏)的方法/技巧。 I have search all over and all I have found was "overflow-x:hidden". 我到处搜索,发现的全部是“ overflow-x:hidden”。 The issue with that is i have to drag an element from one div to another 问题是我必须将元素从一个div拖到另一个

im working on a jquery ui based page where a user can drag a div from one container to another container. 我在基于jQuery用户界面的页面上工作,用户可以在其中将div从一个容器拖动到另一个容器。 the first side is dynamically populated with divs from the database. 第一面是使用数据库中的div动态填充的。 I need verticle scrolling because it's a dynamically populated list, but with horizontal scrolling enable it prevents the divs from being able to be dragged over to the droppable area. 我需要垂直滚动,因为它是一个动态填充的列表,但是通过水平滚动启用,它可以防止将div拖动到可放置区域。

You haven't said, so I will assume you are using jQuery to do dragging. 您还没有说,所以我假设您正在使用jQuery进行拖动。 In the jQuery docs on Draggable , there is an option called 'scroll'. Draggable上jQuery文档中 ,有一个名为“ scroll”的选项。 If you set it to false, draggable objects will not scroll the window. 如果将其设置为false,则可拖动对象将不会滚动窗口。

This is a fairly common problem. 这是一个相当普遍的问题。 Have a look at this page . 看一下这个页面 It describes a workaround To this problem by appending the draggable to a different element ondragstart and reappending it to its original container ondragend . 它通过将可拖动对象附加到其他元素ondragstart并将其重新附加到其原始容器ondragend ,描述了此问题的解决方法。

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

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