用js实现的一个小程序(对一块区域的放大,缩小)

//css

<style type="text/css">

#enlarge1{position:absolute;width:100px; height:100px; border:1px solid #000;}
#enlarge2{position:absolute; top:100px; width:100px; height:200px ;margin-top:20px; border:1px solid #000; }
#enlarge3{position:absolute; top:10px; left:110px;width:200px; height:312px; margin-left:10px; margin-top:-2px; border:1px solid #000; }
</style>

//html

<div id="enlarge1"></div>
<div id="enlarge2"></div>
<div id="enlarge3"></div>

//js

<script type="text/javascript">
function enlargeFc(id,x,y){
var option=document.getElementById(id);
var optionWidth=option.clientWidth;
var optionHeight=option.clientHeight;

option.οnmοuseοver=function(){
this.style.width=optionWidth*x+"px";
this.style.height=optionHeight*y+"px";
this.style.background="#0f0";
this.style.zIndex=100000;
}
option.οnmοuseοut=function(){
this.style.width=optionWidth+"px";
this.style.height=optionHeight+"px";
this.style.background="";
this.style.zIndex="auto";
}

}
enlargeFc("enlarge2",1,1);
</script>

//效果

转载于:https://www.cnblogs.com/fangdx/p/3645386.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值