javascript 动态改变层的大小
来源:互联网 发布:恋母情结 知乎 编辑:程序博客网 时间:2024/06/03 20:11
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>动态设置层的大小</title>
<style type="text/css">
.divMain
{
width:10px;
height:100px;
border-style:solid;
border-width:1px;
border-color:Green;
display:none;
}
</style>
<script type="text/javascript">
var setIntervalID;
function ZoomDiv() {
var divMain = document.getElementById("divMain");
divMain.style.width = "200px";
divMain.style.height = "200px";
}
function ShowDiv() {
setIntervalID = setInterval("inc()", 100);
}
function inc() {
var divMain = document.getElementById("divMain2");
//div不能设置class,否则使用divMain.style.width取到的值时空的
//只能在元素里设置style="width:10px;height:100px"
var oldWidth = divMain.style.width;
var oldHeight = divMain.style.height;
oldWidth = parseInt(oldWidth);
oldHeight = parseInt(oldHeight);
oldWidth += 1;
oldHeight += 1;
if (oldWidth >= 200) {
//清除定时器
clearInterval(setIntervalID);
return;
}
divMain.style.width = oldWidth + "px";
divMain.style.height = oldHeight + "px";
}
</script>
</head>
<body>
<input type="button" value="放大层" onclick="ZoomDiv()" />
<input type="button" value="动态放大层" onclick="ShowDiv()" />
<div id="divMain" class="divMain">
案例:跟着鼠标飞的图片。提示:鼠标移动的事件时onmousemove,通过
window.event的clientX,clientY属性获得鼠标的位置
</div>
<!--这里不能设置class,否则使用divMain.style.width取到的值时空的-->
<div id="divMain2" style="width:10px;height:100px;background-color:Red;">
案例:跟着鼠标飞的图片。提示:鼠标移动的事件时onmousemove,通过
window.event的clientX,clientY属性获得鼠标的位置
</div>
</body>
</html>
<head>
<title>动态设置层的大小</title>
<style type="text/css">
.divMain
{
width:10px;
height:100px;
border-style:solid;
border-width:1px;
border-color:Green;
display:none;
}
</style>
<script type="text/javascript">
var setIntervalID;
function ZoomDiv() {
var divMain = document.getElementById("divMain");
divMain.style.width = "200px";
divMain.style.height = "200px";
}
function ShowDiv() {
setIntervalID = setInterval("inc()", 100);
}
function inc() {
var divMain = document.getElementById("divMain2");
//div不能设置class,否则使用divMain.style.width取到的值时空的
//只能在元素里设置style="width:10px;height:100px"
var oldWidth = divMain.style.width;
var oldHeight = divMain.style.height;
oldWidth = parseInt(oldWidth);
oldHeight = parseInt(oldHeight);
oldWidth += 1;
oldHeight += 1;
if (oldWidth >= 200) {
//清除定时器
clearInterval(setIntervalID);
return;
}
divMain.style.width = oldWidth + "px";
divMain.style.height = oldHeight + "px";
}
</script>
</head>
<body>
<input type="button" value="放大层" onclick="ZoomDiv()" />
<input type="button" value="动态放大层" onclick="ShowDiv()" />
<div id="divMain" class="divMain">
案例:跟着鼠标飞的图片。提示:鼠标移动的事件时onmousemove,通过
window.event的clientX,clientY属性获得鼠标的位置
</div>
<!--这里不能设置class,否则使用divMain.style.width取到的值时空的-->
<div id="divMain2" style="width:10px;height:100px;background-color:Red;">
案例:跟着鼠标飞的图片。提示:鼠标移动的事件时onmousemove,通过
window.event的clientX,clientY属性获得鼠标的位置
</div>
</body>
</html>
- javascript 动态改变层的大小
- 改变层的大小
- javascript动态改变div大小
- javascript div动态大小改变
- javascript div动态大小改变
- javascript 动态改变框架frame,iframe的大小
- 使用JavaScript实现动态改变控件大小
- 动态改变ImageView的大小
- 鼠标拖动改变层的大小
- javascript动态改变层的Z-INDEX的代码style.zIndex
- javascript 动态改变层的Z-INDEX的代码style.zIndex
- 动态改变showModalDialog窗体的大小
- 动态改变模态窗口的大小
- c# 动态改变控件大小的方法
- 动态改变对话框中控件的大小
- c# 动态改变panel大小的问题
- Android 动态改变控件的大小
- 如何动态改变框架的大小[转]
- 移动云计算中选择推广应用程序的战术
- Property's synthesized getter follows Cocoa naming convention for returning 'owned' objects
- 万达感受2012-12-27
- shell里取oracle表的值和连接roacle进行数据处理两种方式
- JSON 基础语法讲解,以及操作
- javascript 动态改变层的大小
- mac,xcode快捷键
- oracle listener.ora,sqlnet.ora,tnsnames.ora配置说明
- C++中类的内存分配简单总结
- ucosii在stm32上的移植详解1
- Excel导出
- Android adb的常用命令
- 为什么打开Excel 表格会自动打印
- linux系统版本库问题