js实现简易画廊

JS实现简易画廊

鼠标单击任一个图像超链接,在底部浮动框架中显示大图像
运行效果

<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>简易灯箱画廊设计</title>
	<style>
	*{
		margin: 0;
	}
		#total{
			width:100%;
			background-color: green;
			height:1000px;
		}
        #fpic{
        	margin-left: 15%;
        }
		.pic{
			margin : 50px;
			width: 100px;
			height: 100px;
		}
		#show-bigger{
			margin: auto;
			width: 600px;
			height: 450px;
			background-color: red;
		}
	</style>
</head>
<body >
<div id="total">
<h3 style="color: white;text-align:center;">简易画廊设计</h3>	
<hr color="red">
<img  class="pic" id="fpic"src="trees/t1.jpg" onclick="myfunction(this)" tabIndex=1 onblur="myfunction1(this)">
<img  class="pic" src="trees/t2.jpg" onclick="myfunction(this)"  tabIndex=1 onblur="myfunction1(this)">
<img  class="pic" src="trees/t3.jpg" onclick="myfunction(this)" tabIndex=1 onblur="myfunction1(this)">
<img  class="pic" src="trees/t4.jpg" onclick="myfunction(this)" tabIndex=1 onblur="myfunction1(this)">
<img  class="pic" src="trees/t5.jpg" onclick="myfunction(this)" tabIndex=1 onblur="myfunction1(this)">
<img  class="pic" src="trees/t6.jpg" onclick="myfunction(this)" tabIndex=1 onblur="myfunction1(this)">
<div id="show-bigger"><img  id="spic" src="trees/t1.jpg" style="width: 100%;height: 100%"></div>
</div>
</body>
<script type="text/javascript">
	function myfunction(x){                          //改变展示框的图片和被选中展示图片的边框
		document.getElementById("spic").src=x.src;
		x.style.borderBottom="5px solid red";
	}
	function myfunction1(x){     //消除未选择的边框属性
		x.style.border="none";        
	}
</script>
</html>

猜你喜欢

转载自blog.csdn.net/weixin_42356649/article/details/88723255
今日推荐