You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
100 lines
2.9 KiB
100 lines
2.9 KiB
3 weeks ago
|
<!DOCTYPE html>
|
||
|
<html lang="zh">
|
||
|
<head>
|
||
|
<meta charset="UTF-8">
|
||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||
|
<title>星座和属相查询</title>
|
||
|
<style>
|
||
|
body {
|
||
|
font-family: Arial, sans-serif;
|
||
|
display: flex;
|
||
|
justify-content: center;
|
||
|
align-items: center;
|
||
|
height: 100vh;
|
||
|
margin: 0;
|
||
|
background-color: #f0f0f0;
|
||
|
}
|
||
|
.container {
|
||
|
background-color: white;
|
||
|
padding: 2rem;
|
||
|
border-radius: 8px;
|
||
|
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
|
||
|
max-width: 400px;
|
||
|
width: 100%;
|
||
|
}
|
||
|
h1 {
|
||
|
text-align: center;
|
||
|
color: #333;
|
||
|
}
|
||
|
form {
|
||
|
display: flex;
|
||
|
flex-direction: column;
|
||
|
}
|
||
|
label {
|
||
|
margin-bottom: 0.5rem;
|
||
|
color: #666;
|
||
|
}
|
||
|
input {
|
||
|
padding: 0.5rem;
|
||
|
margin-bottom: 1rem;
|
||
|
border: 1px solid #ddd;
|
||
|
border-radius: 4px;
|
||
|
}
|
||
|
button {
|
||
|
padding: 0.5rem;
|
||
|
background-color: #4CAF50;
|
||
|
color: white;
|
||
|
border: none;
|
||
|
border-radius: 4px;
|
||
|
cursor: pointer;
|
||
|
transition: background-color 0.3s;
|
||
|
}
|
||
|
button:hover {
|
||
|
background-color: #45a049;
|
||
|
}
|
||
|
#result {
|
||
|
margin-top: 1rem;
|
||
|
text-align: center;
|
||
|
font-weight: bold;
|
||
|
color: #333;
|
||
|
}
|
||
|
</style>
|
||
|
</head>
|
||
|
<body>
|
||
|
<div class="container">
|
||
|
<h1>星座和属相查询</h1>
|
||
|
<form id="zodiacForm">
|
||
|
<label for="birthdate">请输入您的生日:</label>
|
||
|
<input type="date" id="birthdate" required>
|
||
|
<button type="submit">查询</button>
|
||
|
</form>
|
||
|
<div id="result"></div>
|
||
|
</div>
|
||
|
|
||
|
<script>
|
||
|
document.getElementById('zodiacForm').addEventListener('submit', function(e) {
|
||
|
e.preventDefault();
|
||
|
const birthdate = document.getElementById('birthdate').value;
|
||
|
|
||
|
fetch('zodiac.php', {
|
||
|
method: 'POST',
|
||
|
headers: {
|
||
|
'Content-Type': 'application/x-www-form-urlencoded',
|
||
|
},
|
||
|
body: 'birthdate=' + encodeURIComponent(birthdate)
|
||
|
})
|
||
|
.then(response => response.json())
|
||
|
.then(data => {
|
||
|
document.getElementById('result').innerHTML = `
|
||
|
您的星座是:${data.zodiac}<br>
|
||
|
您的属相是:${data.chineseZodiac}
|
||
|
`;
|
||
|
})
|
||
|
.catch(error => {
|
||
|
console.error('Error:', error);
|
||
|
document.getElementById('result').innerHTML = '查询出错,请稍后再试。';
|
||
|
});
|
||
|
});
|
||
|
</script>
|
||
|
</body>
|
||
|
</html>
|