编写一个代码gin框架下的登录用到html,scc,js
时间: 2024-02-21 16:59:35 浏览: 21
好的,以下是一个简单的GIN框架登录页面的HTML、CSS和JS代码:
HTML代码(login.html):
```html
<!DOCTYPE html>
<html>
<head>
<title>Login page</title>
<link rel="stylesheet" type="text/css" href="/static/css/style.css">
</head>
<body>
<div class="login-box">
<h2>Login</h2>
<form>
<div class="user-box">
<input type="text" name="username" required="">
<label>Username</label>
</div>
<div class="user-box">
<input type="password" name="password" required="">
<label>Password</label>
</div>
<button type="submit" class="login-btn">Login</button>
</form>
</div>
</body>
</html>
```
CSS代码(style.css):
```css
* {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: sans-serif;
}
body {
background: #1a1a1a;
}
.login-box {
width: 320px;
height: 420px;
background: #191919;
color: #fff;
top: 50%;
left: 50%;
position: absolute;
transform: translate(-50%, -50%);
box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
padding: 70px 30px;
}
h2 {
margin: 0;
padding: 0 0 20px;
text-align: center;
font-size: 22px;
}
.login-box input[type="text"],
.login-box input[type="password"] {
border: none;
border-bottom: 1px solid #fff;
background: transparent;
outline: none;
height: 40px;
color: #fff;
font-size: 16px;
}
.login-box input[type="submit"] {
border: none;
outline: none;
height: 40px;
background: #e60000;
color: #fff;
font-size: 18px;
border-radius: 20px;
}
.login-btn {
border: none;
outline: none;
height: 40px;
background: #e60000;
color: #fff;
font-size: 18px;
border-radius: 20px;
cursor: pointer;
}
.user-box {
position: relative;
}
.user-box input {
width: 100%;
padding: 10px 0;
font-size: 16px;
color: #fff;
margin-bottom: 30px;
border: none;
border-bottom: 1px solid #fff;
outline: none;
background: transparent;
}
.user-box label {
position: absolute;
top: 0;
left: 0;
padding: 10px 0;
font-size: 16px;
color: #fff;
pointer-events: none;
transition: 0.5s;
}
.user-box input:focus ~ label, .user-box input:valid ~ label {
top: -20px;
left: 0;
color: #e60000;
font-size: 12px;
}
```
JS代码(login.js):
```js
// 可以在这里添加一些登录验证的逻辑
```
这里只是一个简单的演示,具体的登录验证逻辑需要根据实际情况进行编写。同时,需要注意静态文件(css, js)需要被加载,所以还需要在GIN框架中进行相关配置,确保静态文件能够被正确加载。