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

本文介绍了一种使用HTML、CSS及JavaScript实现元素鼠标悬停时放大的效果。通过修改元素的宽度和高度,并调整背景颜色来增强用户体验。文章提供了完整的代码示例。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

//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; }

//html

id="enlarge2">

//js

function enlargeFc(id,x,y){

var

option=document.getElementById(id);

var

optionWidth=option.clientWidth;

var optionHeight=option.clientHeight;

option.onmouseover=function(){

this.style.width=optionWidth*x+"px";

this.style.height=optionHeight*y+"px";

this.style.background="#0f0";

this.style.zIndex=100000;

}

option.onmouseout=function(){

this.style.width=optionWidth+"px";

this.style.height=optionHeight+"px";

this.style.background="";

this.style.zIndex="auto";

}

}

enlargeFc("enlarge2",1,1);

//效果

0c22e3f8ed009a6cdf14c47478d70c72.png

原文:http://www.cnblogs.com/fangdx/p/3645386.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值