二维码显示与隐藏

二维码显示与隐藏

鼠标进入
在这里插入图片描述
鼠标离开
在这里插入图片描述

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
	<style type="text/css">
		.small{
			width: 50px;
			height: 50px;
			background: url(images/code.jpg) no-repeat;
			background-size: 50px 50px;
			position: fixed;
			right: 10px;
			top: 40%;
		}
		.first,.second{
			width: 80px;
			height: 80px;
			position: absolute;
		}
		.first{
			top: 0;
			left: -30px;
		}
		.second{
			top: 80px;
			left: -30px;

		}
		.hide{
			display: none;
		}
		.show{
			display: block;
		}
		.small a{
			display: block;
			width: 50px;
			height: 50px;
		}
	</style>
</head>
<body>
	<div class="small" id="small">
		<a href=""></a>
		<div class="hide" id="big">
			<img class="first" src="images/code1.jpg">
			<img class="second" src="images/code2.jpg">
		</div>
	</div>
	<script type="text/javascript">
		var mask = document.getElementById("small").getElementsByTagName("a")[0];
		mask.onmouseover = function () {
			document.getElementById("big").className = "show";
		};
		mask.onmouseout = function () {
			document.getElementById("big").className = "hide";
		};
	</script>
</body>
</html>
发布了116 篇原创文章 · 获赞 4 · 访问量 1772

猜你喜欢

转载自blog.csdn.net/qq_43618136/article/details/104251349