【发布时间】:2015-06-15 05:10:20
【问题描述】:
如图所示,我想通过向上拖动来调整“文档图标”Div 的大小,并且应该通过降低“文档查看器”的高度来适应它。我需要一个临时滑块来显示屏幕上的拖动。
问题已修改:HTML
<div id="centerDiv" class="centerDiv" style="position:relative;float: left;width: 63%;height: 600px;border-right: 10px solid #ddd;">
<div class="header" style="width: 100%;height: 15px;background-color: #ddd;"></div>
<div class="documentViewer" id="documentViewer" style="width: 100%;height: 500px;margin-bottom: 5px;">
<iframe id="frameValue" name="frameValue" src="NoDocument.html" width="100%" height="500px" style="margin-bottom: 5px;"></iframe>
</div>
<div class="dragDiv" id="dragDiv" style="width: 100%;height: 15px;cursor: row-resize;background-color: green;"></div>
<div class="iconList" id="iconParent" style="position:relative;width: 100%;height: 70px;background-color: #ddd;"></div>
Jquery
$('#dragBar').mousedown(function(e) {
e.preventDefault();
dragging = true;
var main = $('#documentViewer');
var scrollBar = $("<div>'",
{id:'scrollBar',
css: {
height: '5px',
top:'530px',
left:'40px',
z-index:'100',
background-color: 'red'
}
}).appendTo('body');
$(document).mousemove(function(e) {
scrollBar.css("top",e.pageX+2);
});
if(dragging) {
$(window).mouseup(function(e) {
$('#position').html(e.pageX +', '+ e.pageY);
$('#iconParent').css("height",e.pageY+2);
$('#documentViewer').css("height",(600-(e.pageY+30)));
$(document).unbind('mousemove');
});
}
});
【问题讨论】:
-
请在此处移植您的代码
-
希望你得到答案。看看这个答案。 stackoverflow.com/a/20722118/2818107
标签: jquery html css resize draggable