如何使元素在整个页面上可拖动。现在它只允许我在父 div 中拖动我的元素。
$(thumb).draggable()
我正在使用这个库:http: //touchpunch.furf.com/
var thumb = document.createElement("img");
$(thumb).draggable({containment: "html"});
thinner.appendChild(thumb);
如何使元素在整个页面上可拖动。现在它只允许我在父 div 中拖动我的元素。
$(thumb).draggable()
我正在使用这个库:http: //touchpunch.furf.com/
var thumb = document.createElement("img");
$(thumb).draggable({containment: "html"});
thinner.appendChild(thumb);
This should work:
$(thumb).draggable({containment: "body"});
In addition to containment, you may have to use the appendTo option to have your helper appended to the body while you drag it:
$(thumb).draggable({containment: "body", appendTo: "body"});
如果要使用$(thumb).draggable({containment: "body"});
,则必须将其添加到 CSS 中。
body{
overflow: hidden;
}
否则使用:
$(thumb).draggable({containment: "html"});
演示(无 CSS):http: //jsbin.com/ukotit/7/edit
演示(使用 CSS):http: //jsbin.com/ukotit/5/edit
尝试.draggable({containment: "body", scroll: false})