写一段jsp代码,实现用户登录页面,图片背景可以通过鼠标滑动验证
时间: 2024-03-05 21:49:05 浏览: 17
以下是一个简单的 JSP 用户登录页面代码,其中包含一个鼠标滑动验证的图片背景:
```jsp
<!DOCTYPE html>
<html>
<head>
<title>用户登录</title>
<style>
.bg-img {
background-image: url("background.jpg");
background-size: cover;
height: 100vh;
display: flex;
align-items: center;
justify-content: center;
position: relative;
}
#login-form {
background-color: white;
padding: 20px;
border-radius: 5px;
box-shadow: 0px 0px 10px 0px rgba(0,0,0,0.5);
width: 300px;
text-align: center;
}
#login-form input {
margin: 10px 0;
padding: 10px;
border-radius: 5px;
border: none;
box-shadow: 0px 0px 5px 0px rgba(0,0,0,0.5);
width: 100%;
font-size: 16px;
}
#login-form button {
background-color: #4CAF50;
color: white;
padding: 10px;
border: none;
border-radius: 5px;
font-size: 16px;
cursor: pointer;
width: 100%;
}
#slider {
position: absolute;
bottom: 0;
left: 0;
height: 50px;
width: 100%;
background: #eee;
display: flex;
align-items: center;
justify-content: center;
font-size: 20px;
color: #888;
font-weight: bold;
cursor: pointer;
transition: all 0.5s;
}
#slider:before {
content: "";
position: absolute;
top: 0;
left: 0;
height: 50px;
width: 50px;
background: white;
border-radius: 25px;
box-shadow: 0px 0px 5px 0px rgba(0,0,0,0.5);
z-index: 2;
transition: all 0.5s;
}
#slider:hover {
background: #4CAF50;
color: white;
}
#slider:hover:before {
background: #eee;
transform: translateX(250px);
}
</style>
</head>
<body>
<div class="bg-img">
<form id="login-form" action="login.jsp" method="post">
<h2>用户登录</h2>
<input type="text" name="username" placeholder="用户名" required>
<input type="password" name="password" placeholder="密码" required>
<button type="submit">登录</button>
</form>
<div id="slider">请滑动验证</div>
</div>
</body>
</html>
```
当用户点击登录按钮时,表单数据将被提交到名为 `login.jsp` 的页面进行验证和处理。如果用户名和密码正确,则用户将被重定向到另一个页面。否则,登录页面将重新加载,并显示错误消息。