原创 吴旭东 无限大infinity
第一款–简约风格
HTML
:
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="styles.css">
<title>登录界面</title>
</head>
<body>
<div class="login-container">
<h1>欢迎回来</h1>
<form id="loginForm" onsubmit="return handleSubmit()">
<div class="input-group">
<label for="username">用户名</label>
<input type="text" id="username" placeholder="输入用户名" required>
</div>
<div class="input-group">
<label for="password">密码</label>
<input type="password" id="password" placeholder="输入密码" required>
</div>
<button type="submit">登录</button>
</form>
<div id="message"></div>
<div class="footer">
<a href="#">忘记密码?</a>
</div>
</div>
<script src="script.js"></script>
</body>
</html>
CSS (styles.css)
:
body {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
background: linear-gradient(135deg, #a8dadc, #ffafcc);
font-family: 'Arial', sans-serif;
}
.login-container {
background: white;
padding: 30px;
border-radius: 10px;
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
max-width: 400px;
width: 100%;
}
h1 {
text-align: center;
color: #333;
}
.input-group {
margin-bottom: 20px;
}
label {
display: block;
margin-bottom: 5px;
font-weight: bold;
color: #555;
}
input {
width: 100%;
padding: 12px;
border: 1px solid #ccc;
border-radius: 5px;
transition: border-color 0.3s;
box-sizing: border-box; /* 确保padding不超出宽度 */
}
input:focus {
border-color: #007bff;
outline: none;
}
button {
width: 100%;
padding: 12px;
background-color: #96dee0;
color: white;
border: none;
border-radius: 5px;
font-weight: bold;
cursor: pointer;
transition: background-color 0.3s;
}
button:hover {
background-color: #0056b3;
}
#message {
text-align: center;
margin-top: 15px;
color: red;
}
.footer {
text-align: center;
margin-top: 20px;
}
.footer a {
color: #6e747a;
text-decoration: none;
}
.footer a:hover {
text-decoration: underline;
}
JavaScript (script.js)
:
function handleSubmit() {
const username = document.getElementById('username').value;
const password = document.getElementById('password').value;
const messageElement = document.getElementById('message');
// 这里可以简单验证用户名和密码
if (username === 'user' && password === 'pass') {
messageElement.textContent = '登录成功!';
messageElement.style.color = 'green';
} else {
messageElement.textContent = '用户名或密码错误!';
messageElement.style.color = 'red';
}
// 阻止表单的默认提交行为
return false;
}
第二款–雪花飘落
以下是一个简单的登录页面示例,使用HTML、CSS和JavaScript创建,背景为雪花飘落的效果。我们将使用CSS动画和JavaScript来实现雪花效果。
HTML
:
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="styles.css">
<title>登录页面</title>
</head>
<body>
<div class="snowflakes" aria-hidden="true">
<div class="snowflake">❄</div>
<div class="snowflake">❄</div>
<div class="snowflake">❄</div>
<div class="snowflake">❄</div>
<div class="snowflake">❄</div>
<div class="snowflake">❄</div>
<div class="snowflake">❄</div>
<div class="snowflake">❄</div>
<div class="snowflake">❄</div>
<div class="snowflake">❄</div>
</div>
<div class="login-container">
<h1>欢迎回来</h1>
<form id="login-form">
<input type="text" placeholder="用户名" required>
<input type="password" placeholder="密码" required>
<button type="submit">登录</button>
</form>
<div id="message" class="message"></div>
</div>
<script src="script.js"></script>
</body>
</html>
CSS (styles.css)
:
body {
margin: 0;
font-family: 'Arial', sans-serif;
background-color: #282c34;
overflow: hidden;
}
.snowflakes {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
pointer-events: none;
overflow: hidden;
z-index: 1;
}
.snowflake {
position: absolute;
top: -10%;
color: white;
font-size: 1em;
opacity: 0.8;
animation: fall linear infinite;
}
@keyframes fall {
0% {
transform: translateX(0);
top: -10%;
}
100% {
transform: translateX(20px);
top: 100%;
}
}
/* 使雪花飘落更具随机性 */
.snowflake:nth-of-type(1) { left: 10%; animation-duration: 3s; }
.snowflake:nth-of-type(2) { left: 20%; animation-duration: 5s; }
.snowflake:nth-of-type(3) { left: 30%; animation-duration: 6s; }
.snowflake:nth-of-type(4) { left: 40%; animation-duration: 4s; }
.snowflake:nth-of-type(5) { left: 50%; animation-duration: 7s; }
.snowflake:nth-of-type(6) { left: 60%; animation-duration: 5s; }
.snowflake:nth-of-type(7) { left: 70%; animation-duration: 3.5s; }
.snowflake:nth-of-type(8) { left: 80%; animation-duration: 6.5s; }
.snowflake:nth-of-type(9) { left: 90%; animation-duration: 7s; }
.snowflake:nth-of-type(10) { left: 15%; animation-duration: 4.5s; }
.login-container {
position: relative;
z-index: 2;
max-width: 400px;
margin: 100px auto;
padding: 20px;
background: rgba(255, 255, 255, 0.9);
border-radius: 10px;
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}
h1 {
text-align: center;
color: #333;
}
input {
width: 100%;
padding: 10px;
margin: 10px 0;
border: 1px solid #ccc;
border-radius: 5px;
box-sizing: border-box; /* 确保padding不超出宽度 */
}
button {
padding: 10px;
width: 100%;
background-color: #007bff;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
transition: background-color 0.3s;
}
button:hover {
background-color: #0056b3;
}
.message {
text-align: center;
margin-top: 10px;
color: red;
}
JavaScript (script.js)
:
document.getElementById('login-form').addEventListener('submit', function(event) {
event.preventDefault(); // 防止表单提交及页面刷新
// 模拟登录验证
const message = document.getElementById('message');
message.textContent = '登录成功!欢迎!';
message.style.color = 'green';
// 在这里可以添加进一步的验证和操作
});
第三款–中国风
HTML
:
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="styles.css">
<title>中国风登录页面</title>
</head>
<body>
<div class="container">
<div class="login-container">
<h1>欢迎回来</h1>
<form id="login-form">
<input type="text" placeholder="用户名" required>
<input type="password" placeholder="密码" required>
<button type="submit">登录</button>
</form>
<div id="message" class="message"></div>
</div>
</div>
<script src="script.js"></script>
</body>
</html>
CSS (styles.css)
:
body {
margin: 0;
font-family: 'Microsoft YaHei', 'Arial', sans-serif;
background-image: url('img/1.png');
background-size: cover;
background-position: center;
color: #2c2c2c;
}
.container {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
border-radius: 10px;
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}
.login-container {
width: 340px;
padding: 20px;
background-color: #f9f9f9;
border-radius: 10px;
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
border: 2px solid #bf4a4a;
text-align: center;
}
h1 {
font-size: 24px;
margin-bottom: 20px;
color: #bf4a4a;
}
input {
width: 100%;
padding: 10px;
margin: 10px 0;
border: 2px solid #bf4a4a;
border-radius: 5px;
font-size: 16px;
box-sizing: border-box;
}
button {
padding: 10px;
width: 100%;
background-color: #bf4a4a;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
font-size: 16px;
transition: background-color 0.3s;
}
button:hover {
background-color: #a63939;
}
.message {
text-align: center;
margin-top: 10px;
color: red;
}
.login-container::before {
content: "
标签:size,高颜值,color,font,background,message,六款,border,页面
From: https://www.cnblogs.com/o-O-oO/p/18527579