用html+css写一个好看的from表单
时间: 2023-10-09 20:09:01 浏览: 96
当然可以!以下是一个使用 HTML 和 CSS 创建的简单且好看的表单示例:
```html
<!DOCTYPE html>
<html>
<head>
<title>美观的表单</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f1f1f1;
}
.container {
max-width: 400px;
margin: 0 auto;
padding: 20px;
background-color: #fff;
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;
font-weight: bold;
margin-bottom: 5px;
}
input[type="text"],
input[type="email"],
textarea {
width: 100%;
padding: 10px;
border: 1px solid #ccc;
border-radius: 3px;
box-sizing: border-box;
}
textarea {
height: 100px;
}
input[type="submit"] {
background-color: #4CAF50;
color: #fff;
border: none;
padding: 10px 20px;
border-radius: 3px;
cursor: pointer;
}
input[type="submit"]:hover {
background-color: #45a049;
}
</style>
</head>
<body>
<div class="container">
<h2>联系我们</h2>
<form>
<div class="form-group">
<label for="name">姓名:</label>
<input type="text" id="name" name="name" required>
</div>
<div class="form-group">
<label for="email">邮箱:</label>
<input type="email" id="email" name="email" required>
</div>
<div class="form-group">
<label for="message">留言:</label>
<textarea id="message" name="message" required></textarea>
</div>
<input type="submit" value="提交">
</form>
</div>
</body>
</html>
```
这个表单使用了一个容器(`.container`)来包裹表单元素,使其居中显示。使用 CSS 样式对表单进行了美化,包括背景色、边框、阴影、边距、字体等。你可以根据需要进行进一步的调整和定制。
希望这个示例能够满足你的需求!