jQuery可拖动的位置错误

时间:2014-10-05 13:41:43

标签: jquery draggable

我有jQuery的问题:(

HTML:

<div id = 'container'>
<div class = 'draggable' style="margin: auto; left: 0; right: 0; top: 50%; bottom: 50%; background: red;"></div>

JS:

$('.draggable').draggable();

http://jsfiddle.net/EZweB/236/

移动无法正常工作,不知道如何处理

1 个答案:

答案 0 :(得分:0)

容易做到:删除

position:absolute;

来自CSS的

检查:http://jsfiddle.net/ryc461h1/ 干杯!

更改javascript:

$('.draggable').draggable({
    start: function( event, ui ) {
        $(this).css('position','relative');
    },
    drag: function( event, ui ) {
        $(this).removeAttr("style");
    }
    });

检查:http://jsfiddle.net/bevrk06p/