请着重实现右上角二维码的半隐藏半显示效果,可用图片代替
时间: 2024-03-10 18:44:05 浏览: 17
好的,以下是一个简单的实现右上角二维码半隐藏半显示效果的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的边框属性来实现。