用H5画一个带样式的登录页面
时间: 2023-10-28 15:04:50 浏览: 40
好的,下面是一个简单的登录页面的代码示例:
```html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Login Page</title>
<style>
body {
background-color: #f2f2f2;
font-family: Arial, sans-serif;
}
h1 {
text-align: center;
font-size: 2em;
margin-top: 50px;
margin-bottom: 30px;
}
form {
max-width: 400px;
margin: 0 auto;
background-color: #ffffff;
border-radius: 5px;
padding: 20px;
box-shadow: 0px 0px 10px #c4c4c4;
}
label {
display: block;
font-size: 1.2em;
font-weight: bold;
margin-bottom: 10px;
}
input[type="text"],
input[type="password"] {
width: 100%;
padding: 10px;
border-radius: 3px;
border: 1px solid #ccc;
margin-bottom: 20px;
}
button {
background-color: #4CAF50;
color: #ffffff;
border: none;
padding: 10px;
border-radius: 3px;
font-size: 1.2em;
cursor: pointer;
}
button:hover {
background-color: #3e8e41;
}
</style>
</head>
<body>
<h1>Login</h1>
<form>
<label for="username">Username</label>
<input type="text" id="username" name="username" placeholder="Enter your username">
<label for="password">Password</label>
<input type="password" id="password" name="password" placeholder="Enter your password">
<button type="submit">Login</button>
</form>
</body>
</html>
```
该页面使用了 HTML 和 CSS 来创建一个简单的登录页面。在页面中,我们使用了以下 CSS 属性:
- `background-color`:用于设置页面的背景颜色。
- `font-family`:用于设置页面中的字体。
- `text-align`:用于设置标题的对齐方式。
- `font-size`:用于设置标题的字体大小。
- `margin-top` 和 `margin-bottom`:用于设置标题的上下边距。
- `max-width` 和 `margin`:用于设置表单的最大宽度和水平居中对齐。
- `background-color`、`border-radius`、`padding` 和 `box-shadow`:用于给表单添加样式。
- `display`、`font-size`、`font-weight` 和 `margin-bottom`:用于给标签添加样式。
- `width`、`padding`、`border-radius`、`border` 和 `margin-bottom`:用于给输入框添加样式。
- `background-color`、`color`、`border`、`padding`、`border-radius`、`font-size` 和 `cursor`:用于给按钮添加样式。
在这个页面中,我们使用了一个 `<form>` 元素来包含输入框和提交按钮,并使用 `<label>` 元素来标记每个输入框。当用户点击提交按钮时,表单将被提交到服务器并触发一个事件。
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)