用css+html+js,编写一个旅游网的评价表单
时间: 2024-03-24 19:36:27 浏览: 94
一个简单的旅游网页的前端开发html以及css、js
好的,以下是一个简单的旅游网的评价表单的示例代码,你可以根据需要进行修改和优化:
HTML代码:
```html
<!DOCTYPE html>
<html>
<head>
<title>旅游网评价表单</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div class="form-container">
<h1>旅游网评价表单</h1>
<form>
<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" required>
<label for="destination">旅游目的地:</label>
<input type="text" id="destination" name="destination" required>
<label for="rating">评分:</label>
<select id="rating" name="rating" required>
<option value="" disabled selected hidden>请选择评分</option>
<option value="1">1分</option>
<option value="2">2分</option>
<option value="3">3分</option>
<option value="4">4分</option>
<option value="5">5分</option>
</select>
<label for="comment">评价:</label>
<textarea id="comment" name="comment" required></textarea>
<input type="submit" value="提交">
</form>
</div>
</body>
</html>
```
CSS代码:
```css
body {
margin: 0;
padding: 0;
font-family: Arial, sans-serif;
background-color: #f2f2f2;
}
.form-container {
max-width: 500px;
margin: 50px auto;
background-color: #fff;
padding: 20px;
border-radius: 5px;
box-shadow: 0 0 10px rgba(0,0,0,0.3);
}
h1 {
text-align: center;
margin-top: 0;
}
label {
display: block;
margin-bottom: 5px;
}
input[type="text"], input[type="email"], input[type="tel"], select, textarea {
display: block;
width: 100%;
padding: 10px;
margin-bottom: 15px;
border: 1px solid #ccc;
border-radius: 5px;
box-sizing: border-box;
}
textarea {
height: 100px;
resize: none;
}
input[type="submit"] {
background-color: #4CAF50;
color: #fff;
padding: 10px 20px;
border: none;
border-radius: 5px;
cursor: pointer;
}
input[type="submit"]:hover {
background-color: #3e8e41;
}
input[type="submit"]:focus {
outline: none;
}
```
JavaScript代码(可选):
```javascript
// 可以使用 JavaScript 对表单进行验证和提交操作
```
阅读全文