标签:
<style>
div{background:#CCCCCC;text-align:center;}
#first{float:left;width:100px; height:150px; line-height:150px;}
#second{clear:left;float:left;margin-top:10px;width:100px;height:150px; line-height:150px;}
#third{zoom:1; width:200px;margin-left:110px; height:310px; line-height:310px;}
</style>
</head>
<body>
<div id="first">A</div>
<div id="second">B</div>
<div id="third">C</div>
</body>
<script>
window.onload = function() {
function zoom(id,x,y){
// 设置缩放函数参数:容器id、横向缩放倍数、纵向缩放倍数(等比例缩放时也可以设定一个参数)
var obj=document.getElementById(id);
// 获取元素对象值
var dW=obj.clientWidth;
// 获取元素宽度
var dH=obj.clientHeight;
// 获取元素高度
//var dW=obj.offsetTop;
//var dH=obj.offsetLeft;
obj.onmouseover=function(){
// 鼠标移入
this.style.width=dW*x+"px";
// 横向缩放
this.style.height=dH*y+"px";
// 纵向缩放
this.style.backgroundColor="#f00";
// 设置调试背景
//this.style.zIndex=1;
// 设置z轴优先
}
obj.onmouseout=function(){
// 鼠标移出,设回默认值
this.style.width="";
this.style.height="";
this.style.padding="";
this.style.backgroundColor="";
this.style.zIndex="";
}
}
zoom("first",1.25,1.25);
zoom("second",1.25,1.25);
zoom("third",1.25,1.25);
}
</script>
标签:
原文地址:http://www.cnblogs.com/liangxuru/p/5698982.html