我试图调整div的大小,就像这里在堆栈溢出编辑器(在编辑器底部)一样。
一切正常工作,直到我将我的div定位在另一个div与一个填充。
载于div中:
载于div中
我用这个来拖拽潜水器。请注意,它正在工作,直到我有一个填充在我的主div。
$('#drag').mousedown(function(e){
$(document).mousemove(function(e){
$('#iframeEditorContainer').css("height",e.pageY);
})
});
$(document).mouseup(function(e){
$(document).unbind('mousemove');
});然后,我通过更改js:工作中中的一行来实现它。
$('#iframeEditorContainer').css("height",e.pageY-80);我做了-80比Y来对抗垫子。问题是我不相信这个-80,我是通过尝试和错误做的,如果我的页面上发生了什么变化,我担心它会把拖拽器搞砸。有更好的方法吗?
发布于 2015-09-09 00:37:53
在这里http://jsfiddle.net/fcoerd0t/3/
获取页面顶部和div之间的高度。
$('#drag').mousedown(function(e){
var top = $('#iframeEditorContainer').offset().top;
$(document).mousemove(function(e){
$('#iframeEditorContainer').css("height",e.pageY-top);
e.preventDefault();
})
});这样,您将始终计算#iframeEditorContainer的高度。
https://stackoverflow.com/questions/32469040
复制相似问题