<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>User Feedback Form</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
box-sizing: border-box;
background-color: #f8f9fa;
}
.container {
max-width: 700px;
margin: 50px auto;
padding: 20px;
background-color: white;
border-radius: 8px;
box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}
h1 {
color: #333;
}
.form-group {
margin-bottom: 15px;
}
.form-group label {
display: block;
margin-bottom: 5px;
}
.form-group input, .form-group textarea, .form-group select {
width: 100%;
padding: 10px;
border: 1px solid #ddd;
border-radius: 5px;
}
.form-group textarea {
resize: vertical;
}
button {
padding: 10px 20px;
border: none;
border-radius: 5px;
background-color: #007bff;
color: white;
font-size: 1em;
cursor: pointer;
}
button:hover {
background-color: #0056b3;
}
.success-message {
color: green;
font-weight: bold;
}
</style>
</head>
<body>
<div class="container">
<h1>User Feedback</h1>
<form id="feedbackForm">
<div class="form-group">
<label for="name">Name:</label>
<input type="text" id="name" name="name" required>
</div>
<div class="form-group">
<label for="email">Email:</label>
<input type="email" id="email" name="email" required>
</div>
<div class="form-group">
<label for="feedback">Feedback:</label>
<textarea id="feedback" name="feedback" rows="4" required></textarea>
</div>
<div class="form-group">
<label for="rating">Rating:</label>
<select id="rating" name="rating">
<option value="1">1 - Very Poor</option>
<option value="2">2 - Poor</option>
<option value="3">3 - Average</option>
<option value="4">4 - Good</option>
<option value="5">5 - Excellent</option>
</select>
</div>
<button type="button" onclick="submitForm()">Submit</button>
</form>
<div id="message" class="success-message"></div>
</div>
<script>
function submitForm() {
const form = document.getElementById('feedbackForm');
if (form.checkValidity()) {
document.getElementById('message').textContent = 'Thank you for your feedback!';
form.reset();
}
}
</script>
</body>
</html>
标签:26,group,反馈表,form,示例,color,background,5px,border
From: https://blog.51cto.com/u_16160172/12056968