htmlcss精美登录界面源码
时间: 2024-02-02 07:01:36 浏览: 28
html和css可以帮助我们设计一个精美的登录界面。以下是一个示例源码:
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>登录界面</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="container">
<h2>用户登录</h2>
<form action="#">
<div class="form-group">
<label for="username">用户名:</label>
<input type="text" id="username" name="username" required>
</div>
<div class="form-group">
<label for="password">密码:</label>
<input type="password" id="password" name="password" required>
</div>
<button type="submit">登录</button>
</form>
</div>
</body>
</html>
```
```css
body {
font-family: Arial, sans-serif;
background: #f4f4f4;
}
.container {
width: 300px;
margin: 100px auto;
background: #fff;
padding: 20px;
border-radius: 5px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
h2 {
text-align: center;
margin-bottom: 20px;
}
.form-group {
margin-bottom: 20px;
}
label {
display: block;
margin-bottom: 5px;
}
input {
width: 100%;
padding: 10px;
border: 1px solid #ccc;
border-radius: 5px;
}
button {
width: 100%;
padding: 10px;
background: #007bff;
border: none;
color: #fff;
border-radius: 5px;
cursor: pointer;
}
```
以上是一个简单的html和css代码,通过给元素添加样式和布局,我们可以设计一个精美的登录界面。希望对您有所帮助!