没有合适的资源?快使用搜索试试~ 我知道了~
本文实例为大家分享了JS实现图片放大效果 ,供大家参考,具体内容如下 <!DOCTYPE html> <html> <head> <meta charset=utf-8/> <title></title> <style type=text/css> #div1 { width:300px; height:300px; position:relative; margin:30px auto 0px; } #div1 img{ width: 300px; } #div1 span { width:1
资源详情
资源评论
资源推荐
![](https://csdnimg.cn/release/download_crawler_static/14805291/bg1.jpg)
JS图片放大效果简单实现代码图片放大效果简单实现代码
本文实例为大家分享了JS实现图片放大效果 ,供大家参考,具体内容如下
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title></title>
<style type="text/css">
#div1 {
width:300px;
height:300px;
position:relative;
margin:30px auto 0px;
}
#div1 img{
width: 300px;
}
#div1 span {
width:150px;
height:150px;
background:red;
position:absolute;
left:0px;
top:0px;
display:none;
opacity:0.2;
}
.show {
width:100%;
height:100%;
background:red;
position:absolute;
left:0px; top:0px;
z-index:10px;
opacity:0.1;
}
#div2 {
width:300px;
height:300px;
position:relative;
top: -300px;
left: 300px;
display:none;
overflow:hidden;
margin:0px auto 0px;
}
#img1 {
position:absolute;
}
</style>
</head>
<body>
<div id="div1">
<!-- 图片 -->
<img src="images/xiangqing.png" alt="">
<!-- 鼠标选中框 -->
<span></span>
<!-- 背景 -->
<div class="show"></div>
</div>
<div id="div2">
<!-- 放大后的图片 -->
<img id="img1" src="images/xiangqingda.png" />
</div>
</body>
<script>
// 加载完成后显示
window.onload=function () {
var oDiv=document.getElementById('div1');
var oShow=document.getElementsByClassName('show')[0];
var oSpan=document.getElementsByTagName('span')[0];
var oImg=document.getElementById('img1');
// parentNode获得父节点
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![application/x-rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![thumb](https://img-home.csdnimg.cn/images/20210720083646.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![avatar](https://profile-avatar.csdnimg.cn/default.jpg!1)
weixin_38650629
- 粉丝: 4
- 资源: 897
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助
![voice](https://csdnimg.cn/release/downloadcmsfe/public/img/voice.245cc511.png)
![center-task](https://csdnimg.cn/release/downloadcmsfe/public/img/center-task.c2eda91a.png)
安全验证
文档复制为VIP权益,开通VIP直接复制
![dialog-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/green-success.6a4acb44.png)
评论0