要求界面美观,语法更丰富
时间: 2023-07-05 08:19:24 浏览: 49
当然,HTML语言本身并不支持通过标记来美化界面,但是我们可以使用CSS样式来达到这个目的。以下是一个更美观的HTML个人信息表单示例:
```html
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<title>个人信息表单</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f2f2f2;
}
form {
margin: 50px auto;
background-color: #fff;
padding: 20px;
max-width: 500px;
border-radius: 10px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
label {
display: block;
font-weight: bold;
margin-bottom: 10px;
}
input[type="text"],
input[type="email"],
input[type="tel"],
select,
textarea {
padding: 10px;
border-radius: 5px;
border: none;
background-color: #eee;
width: 100%;
box-sizing: border-box;
margin-bottom: 20px;
font-size: 16px;
color: #555;
}
input[type="submit"] {
background-color: #2ecc71;
color: #fff;
border: none;
padding: 10px 20px;
border-radius: 5px;
cursor: pointer;
font-size: 16px;
}
input[type="submit"]:hover {
background-color: #27ae60;
}
</style>
</head>
<body>
<form action="#" method="post">
<label for="name">姓名:</label>
<input type="text" id="name" name="name" required>
<label for="email">电子邮件:</label>
<input type="email" id="email" name="email" required>
<label for="phone">电话:</label>
<input type="tel" id="phone" name="phone">
<label for="gender">性别:</label>
<select id="gender" name="gender">
<option value="male">男</option>
<option value="female">女</option>
<option value="other">其他</option>
</select>
<label for="message">留言:</label>
<textarea id="message" name="message" rows="5"></textarea>
<input type="submit" value="提交">
</form>
</body>
</html>
```
这个示例使用了一些CSS样式来美化表单,例如设置背景颜色、圆角、阴影、字体、颜色等。您可以根据自己的需要自由地对它们进行修改。此外,我们还添加了一些交互效果,例如当鼠标悬停在提交按钮上时,背景颜色会变成深绿色。
相关推荐
![](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)
![](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)