二维码显示与隐藏

二维码显示与隐藏

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

<!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>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
好的,以下是一个简单的实现右上角二维码隐藏显示效果的HTML和CSS代码,使用了一个图片代替二维码: ```html <!DOCTYPE html> <html> <head> <title>淘宝登录</title> <link rel="stylesheet" type="text/css" href="style.css"> </head> <body> <div class="login-box"> <h1>淘宝登录</h1> <form> <label for="username">用户名</label> <input type="text" id="username" name="username" placeholder="请输入用户名"> <label for="password">密码</label> <input type="password" id="password" name="password" placeholder="请输入密码"> <input type="submit" value="登录"> </form> <div class="qrcode"> <img src="qrcode.png" alt="二维码"> <div class="arrow"></div> </div> </div> </body> </html> ``` ```css body { background-color: #f2f2f2; font-family: Arial, sans-serif; } .login-box { background-color: #fff; border-radius: 10px; box-shadow: 0 0 10px rgba(0,0,0,0.2); max-width: 400px; margin: 50px auto; padding: 20px; position: relative; text-align: center; } h1 { color: #ff4400; font-size: 32px; margin-bottom: 20px; } form { display: inline-block; text-align: left; } label { display: block; margin-bottom: 5px; } input[type="text"], input[type="password"] { border: 1px solid #ccc; border-radius: 5px; font-size: 16px; margin-bottom: 20px; padding: 10px; width: 100%; } input[type="submit"] { background-color: #ff4400; border: none; border-radius: 5px; color: #fff; cursor: pointer; font-size: 16px; padding: 10px; width: 100%; } input[type="submit"]:hover { background-color: #d63300; } .qrcode { background-color: #fff; border: 1px solid #ccc; border-radius: 5px; box-shadow: 0 0 10px rgba(0,0,0,0.2); position: absolute; right: 0; top: -150px; transition: top 0.3s ease-in-out; width: 200px; z-index: 1; } .qrcode img { display: block; margin: 20px auto; width: 100px; } .qrcode .arrow { background-color: #fff; border-bottom: 10px solid #ccc; border-right: 10px solid transparent; border-top: 10px solid transparent; height: 0; position: absolute; right: 20px; top: -10px; width: 0; } .qrcode:hover { top: -50px; } ``` 注意:由于二维码实际上没有提供给我们,所以这里使用了一个名为`qrcode.png`的图片代替。`qrcode`类是用来定位二维码的容器,它的`top`属性在默认情况下为`-150px`,使得二维码在登录框上方隐藏。当鼠标悬停在`qrcode`容器上时,它的`top`属性将变为`-50px`,显示二维码。`arrow`类是用来绘制箭头的,它是一个等腰直角三角形,利用了CSS的边框属性来实现。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值