在Firefox中它工作得很完美,但在IE、Chrome和Opera中却不起作用。
<div> has position:fixed, and is .draggable()
只有在Firefox浏览器中才能正常工作。
在Firefox中它工作得很完美,但在IE、Chrome和Opera中却不起作用。
<div> has position:fixed, and is .draggable()
只有在Firefox浏览器中才能正常工作。
在CSS中不要设置固定宽度:它在Firefox、Chromium、Safari和Internet Explorer中都可以工作。
var div = $('#id');
div.resizable(
{
stop: function(event, ui)
{
var top = getTop(ui.helper);
ui.helper.css('position', 'fixed');
ui.helper.css('top', top+"px");
}
});
div.draggable(
{
stop: function(event, ui)
{
var top = getTop(ui.helper);
ui.helper.css('position', 'fixed');
ui.helper.css('top', top+"px");
}
});
function getTop(ele)
{
var eTop = ele.offset().top;
var wTop = $(window).scrollTop();
var top = eTop - wTop;
return top;
}
TypeError:$(...)。resizable不是函数;)
。 - Hakan Fıstık只需在您的CSS中使用:
#draggable{
position:fixed !important;
}
function stop(event){
if(event.type === "resizestop"){
var topOff = $(this).offset().top - $(window).scrollTop()
$(this).css("top",topOff)
}
$(this).css("position","fixed")
}
如果您在...draggable(...);上设置了断点, 您会发现它将position:fixed添加到element.style中。
只需使用.style.position ="";撤消它即可。
我的代码清除了样式,这样它就会回到css声明。 对于旧版jquery ui版本,您可能需要执行拖动停止处理程序。但我怀疑。 但最新版本肯定不需要。