简体   繁体   English

问题设置初始可拖动位置jQuery UI

[英]Issue setting initial draggable position jquery ui

I've a problem, when I set container element: 我在设置容器元素时遇到问题:

position: absolute;
left: 10px;
bottom: 15px;

And initialize draggable, bottom part of the element gets stuck to the border, and it is basically resizing rather than dragging. 并初始化可拖动的元素的底部被卡在边框上,它基本上是调整大小而不是拖动。

http://jsfiddle.net/JVSFS/83/ http://jsfiddle.net/JVSFS/83/

So what do I do? 那我该怎么办?

jQuery draggable works by modifying the left and top css properties of an object. jQuery可拖动作品通过修改对象的lefttop CSS属性来工作。

Set the top property instead of the bottom . 设置top属性而不是bottom属性。 I know it sounds like a cheap trick, but it's the fastest solution I found here. 我知道这听起来很便宜,但这是我在这里找到的最快的解决方案。

It is doing what you told it to do. 它正在执行您指示的操作。 When you set bottom to be 10px on an absolutely-positioned element, the bottom of that element will stay 15px from the bottom of its parent container. 当您在绝对定位的元素上将bottom设置为10px ,该元素的底部将与其父容器的底部保持15px的距离。

It might be better in your situation to set the CSS to position:relative using mousedown() in your jQuery. 在您的情况下,最好在jQuery中使用mousedown()将CSS设置为position:relative

You might want to go about it by removing 您可能要删除

.popup_click {position: absolute left: 10px; bottom: 15px;}

and replacing it with: .popup_click {top: 92%; left: 1%;} 并替换为: .popup_click {top: 92%; left: 1%;} .popup_click {top: 92%; left: 1%;}

Fiddle 小提琴

Please note that the percentages are just estimates based on where you had it placed before. 请注意,这些百分比只是根据您之前放置的位置估算出来的。

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

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