繁体   English   中英

使用jQuery事件Drag and Drop处理滚动条

[英]Handling Scroll bars with jQuery event Drag and Drop

我有一个房间div,上面有一些玩具div,请看 替代文字

玩具绝对定位,可以在房间的墙壁上拖动。 房间容器div具有固定的高度和高度,因此房间具有水平和垂直卷轴。 我使用jquery事件拖动插件来设置DnD。 我设法将玩具设置在墙壁的下方,但是当有卷轴时,组件在墙壁上移动一点(仅限于墙壁的实际宽度)。

我想只显示玩具的一部分,如下所示 替代文字

我尝试设置z-index ,但没有效果,任何人都有更好的想法?

看到实际的代码,我想溢出:隐藏可以解决这个问题?

您可以使用scrollTo插件http://demos.flesler.com/jquery/scrollTo/来处理滚动条

下面的例子显示overflow:hidden确实可以满足您的要求。 你的代码有些东西,但除非你发布,否则我们无法帮助你!

替代文字http://img155.imageshack.us/img155/9594/example1281542227415.png

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title>Example</title>

        <style type="text/css">

            #container {
                background-color:#ddddff;
                height:300px;
                overflow:hidden;
                position:relative;
                width:300px;
            }

            #container .child {
                background-color:#ddffdd;
                height:50px;
                position:absolute;
                width:50px;
            }

            #container .child1 {
                left:100px;
                top:70px;
            }

            #container .child2 {
                left:270px;
                top:170px;
            }

        </style>
    </head>

    <body>

        <div id="container">
            <div class="child child1"></div>
            <div class="child child2"></div>
        </div>

    </body>
</html>

暂无
暂无

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

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