2个回答
展开全部
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
<style>
img{ cursor:pointer;}
#big{ width:100%; height:100%; background-color:rgba(0,0,0,0.6); position:fixed; top:0; left:0; z-index:1; display:none;}
#big>img{ display:block; margin:auto;}
</style>
</head>
<body>
<img src="360截图20171002174707912.jpg" />
<img src="ul0541-8146.jpg" />
<img src="360截图20171002174707912.jpg" />
<div id="big"><img id="bigimg" /></div>
<script>
var imgs=document.getElementsByTagName("img");
var big=document.getElementById("big");
var bigimg=document.getElementById("bigimg");
var length=imgs.length;
for(var i=0;i<3;i++){
imgs.item(i).onclick=function(){
big.style.display="block";
bigimg.src=this.src;
}
}
bigimg.onclick=function(){
big.style.display="none";
}
</script>
</body>
</html>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询