用js css html 写一个登录网页
时间: 2023-10-02 07:03:44 浏览: 38
好的,以下是一个简单的登录网页示例:
HTML代码:
```html
<!DOCTYPE html>
<html>
<head>
<title>Login Page</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div class="login-box">
<h1>Login</h1>
<form>
<label for="username">Username</label>
<input type="text" id="username" name="username" required>
<label for="password">Password</label>
<input type="password" id="password" name="password" required>
<button type="submit">Log in</button>
</form>
</div>
</body>
</html>
```
CSS代码:
```css
body {
margin: 0;
padding: 0;
background-color: #f2f2f2;
font-family: sans-serif;
}
.login-box {
width: 300px;
height: 350px;
background-color: #fff;
color: #000;
top: 50%;
left: 50%;
position: absolute;
transform: translate(-50%, -50%);
padding: 50px 30px;
box-sizing: border-box;
border-radius: 10px;
box-shadow: 0 15px 25px rgba(0, 0, 0, 0.5);
}
.login-box h1 {
margin: 0;
padding: 0 0 20px;
text-align: center;
font-size: 30px;
}
.login-box label {
margin: 0;
padding: 0;
font-weight: bold;
display: block;
}
.login-box input {
width: 100%;
margin-bottom: 20px;
}
.login-box input[type="text"],
.login-box input[type="password"] {
border: none;
border-bottom: 1px solid #000;
background: transparent;
outline: none;
height: 40px;
font-size: 16px;
color: #000;
}
.login-box button[type="submit"] {
border: none;
outline: none;
height: 40px;
background: #000;
color: #fff;
font-size: 18px;
border-radius: 20px;
}
.login-box button[type="submit"]:hover {
cursor: pointer;
background: #ffc107;
color: #000;
}
```
这个登录网页包含了一个表单,用户需要输入用户名和密码才能登录。CSS样式用于美化页面,使其更加友好。