最近项目中需要在DashBoard页面做一个事件通知栏,该通知栏固定位于页面底部,鼠标拖动该DIV实现自动改变高度扩展内容显示区域。

以下是一个设计原型,基于jQuery实现,只实现了拖动效果,没有做页面美化,可以根据需求做相应修改。

直接上代码

 <!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xml:lang="en" xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
<title>Div随鼠标拖动改变高度</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script src="jquery-1.8.3.min.js"></script>
<style type="text/css">
html, body{ height: 100%; margin: 0; padding: 0; }
#footer { position:fixed; bottom:0; left:0; width:100%; height:30px; background-color:#B8D0FA;}
#expander{ width:100%; height:6px; background-color:#999;}
#expander:hover{ cursor:n-resize;}
</style>
<script>
$(function(){
var src_posi_Y = 0, dest_posi_Y = 0, move_Y = 0, is_mouse_down = false, destHeight = 30;
$("#expander")
.mousedown(function(e){
src_posi_Y = e.pageY;
is_mouse_down = true;
});
$(document).bind("click mouseup",function(e){
if(is_mouse_down){
is_mouse_down = false;
}
})
.mousemove(function(e){
dest_posi_Y = e.pageY;
move_Y = src_posi_Y - dest_posi_Y;
src_posi_Y = dest_posi_Y;
destHeight = $("#footer").height() + move_Y;
if(is_mouse_down){
$("#footer").css("height", destHeight > 30 ? destHeight : 30);
}
});
});
</script>
</head>
<body>
<div style="width:100%; height:1000px; background-color:#F2F2F2;"></div>
<div id="footer"><div id="expander"></div><span id="info">It's Your Contents !</span></div>
</body>
</html>

jQuery实现鼠标拖动改变Div高度的更多相关文章

  1. 鼠标拖动改变DIV等网页元素的大小的最佳实践

    1.初次实现 1.1 html代码 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" la ...

  2. jquery 拖动改变div大小

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  3. 调用jquery的resize方法改变div的宽度和高度在IE中不变,在谷歌中可以正常显示

    1.jquery代码: 1.1问题的版本: $(function() { haituheight(); $(window).resize(function(){ haituheight(); }); ...

  4. jQuery鼠标拖曳改变div大小(模拟textarea右下角拖曳)

    jQuery.fn.extend({ drag: function() { $(document).off("mouseup.drag").on("mouseup.dra ...

  5. js改变div高度

    用bootsrap响应式布局的时候,遇到个很恶心的问题:左边栏很短很难看!! 于是,想用js来自动改变左边的高度,没成功!!原来是设置的时候,没加单位,坑爹了. 参考:http://blog.sina ...

  6. [置顶] 原创鼠标拖动实现DIV排序

    先上效果图: 对比传统的排序,这是一个很不错的尝试,希望对大家有启发. 大家可以参考我的上一篇博文:http://blog.csdn.net/littlebo01/article/details/12 ...

  7. jquery实现鼠标拖动

    <html>   <head>   <script type='text/javascript' src='js/jquery-1.5.1.js'></scr ...

  8. C# 运行时通过鼠标拖动改变控件的大小

    来源:http://blog.csdn.net/yanleigis/article/details/1819447 using System; using System.Collections.Gen ...

  9. jquery动态改变div宽度和高度

    效果体验:http://keleyi.com/keleyi/phtml/jquery/23.htm 完整代码: <!DOCTYPE html PUBLIC "-//W3C//DTD X ...

随机推荐

  1. suspendlayout

    c# this.suspendlayout有什么作用 为了防止layout事件的发生.这个事件将引发重新绘图的事件,如果介面上控件较多的话,改变控件某些属性时,由于不断地重画,性能变低,所以用susp ...

  2. 汇编语言学习与Makefile入门

    继续开发 ; hello-os ; TAB= ORG 0x7c00 ; 指明程序的装载地址 ; 以下的记述用于标准FAT12格式的软盘 JMP entry DB 0x90 DB "HELLO ...

  3. lucene 内存索引 和文件索引 合并

    IndexWriter.addIndexes(ramDirectory); http://blog.csdn.net/qq_28042463/article/details/51538283 在luc ...

  4. 如何将win7变为wifi热点

    以前经常使用connectify软件一键设置win7热点,但发现该软件影响开机速度,于是研究了一下win7自带的wifi功能,简单方便,分享如下: 1.打开命令提示符: [开始]/搜索框中输入“cmd ...

  5. 搞定迅雷固件在TP-LINK WR720N,127.0.0.1 9000 获取不到激活码

    本帖最后由 exzzzipad 于 2014-7-2 22:33 编辑 基本情况:设备:TP-LINK WR720N目前固件:[antclan][20120825]720N-4M-NAS-withSA ...

  6. PHP二维码生成的方法(google APi,PHP类库,libqrencode等)

    原文地址: http://blog.csdn.net/liuxinmingcode/article/details/7910975 ================================== ...

  7. Node.js 自学之旅

    学习基础,JQuery 原生JS有一定基础,有自己一定技术认知(ps:原型链依然迷糊中.闭包6不起来!哎!) 当然最好有语言基础,C#,java,PHP等等.. 最初学习这个东西的原因很简单,在园子里 ...

  8. html5手写签名

    <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <meta co ...

  9. leetcode72. Edit Distance(编辑距离)

    以下为个人翻译方便理解 编辑距离问题是一个经典的动态规划问题.首先定义dp[i][j表示word1[0..i-1]到word2[0..j-1]的最小操作数(即编辑距离). 状态转换方程有两种情况:边界 ...

  10. excel 怎么去掉单元格中第一个空格或其他特定符号/Excel excel中批量去掉表格中首字母前的空格或特定符号

    =IF(FIND(" ",A160)>1,A160,MID(A160,FIND(" ",A160)+1,LEN(A160)-FIND(" &qu ...