body {
font-family: 'Comic Sans MS', '楷体', cursive, sans-serif;
background: #0c0e1f;
color: #f0e6d6;
min-height: 100vh;
overflow-x: hidden;
position: relative;
}
/* 星空背景效果 */
.stars {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: -1;
}
.star {
position: absolute;
background-color: white;
border-radius: 50%;
animation: twinkle 5s infinite;
}
@keyframes twinkle {
0%, 100% { opacity: 0.2; }
50% { opacity: 1; }
}
.container {
max-width: 800px;
margin: 0 auto;
padding: 30px 20px;
text-align: center;
z-index: 1;
position: relative;
}
header h1 {
font-size: 3.5rem;
margin-bottom: 15px;
color: #c77dff;
text-shadow: 0 0 10px #9d4edd, 0 0 20px #7b2cbf;
letter-spacing: 2px;
}
.subtitle {
font-size: 1.5rem;
margin-bottom: 40px;
color: #e0aaff;
}
.answer-container {
background: rgba(25, 20, 40, 0.7);
border: 2px solid #7b2cbf;
border-radius: 15px;
padding: 40px 20px;
margin: 30px 0;
box-shadow: 0 0 20px rgba(123, 44, 191, 0.5);
min-height: 200px;
display: flex;
align-items: center;
justify-content: center;
}
#answer {
font-size: 2.5rem;
line-height: 1.4;
color: #f8f9fa;
text-shadow: 0 0 5px #ff9ff3;
}
.btn {
background: linear-gradient(135deg, #7b2cbf, #5a189a);
color: white;
border: none;
border-radius: 50px;
padding: 15px 40px;
font-size: 1.5rem;
cursor: pointer;
margin: 20px 0;
transition: all 0.3s ease;
font-family: 'Comic Sans MS', '楷体', cursive;
box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}
.btn:hover {
transform: translateY(-3px);
box-shadow: 0 8px 20px rgba(123, 44, 191, 0.6);
background: linear-gradient(135deg, #9d4edd, #7b2cbf);
}
.btn:active {
transform: translateY(1px);
}
footer {
margin-top: 50px;
padding: 20px;
border-top: 1px solid #3c096c;
color: #e0aaff;
font-size: 1.2rem;
}
.wechat-note {
font-size: 0.9rem;
margin-top: 5px;
color: #c77dff;
}
/* 魔法元素装饰 */
.crystal-ball {
width: 150px;
height: 150px;
background: radial-gradient(circle at 30% 30%, #f8f9fa, #e0aaff);
border-radius: 50%;
margin: 0 auto 30px;
box-shadow: 0 0 30px #9d4edd;
position: relative;
animation: float 6s ease-in-out infinite;
}
.crystal-ball:after {
content: '';
position: absolute;
bottom: -10px;
left: 20%;
width: 60%;
height: 20px;
background: rgba(25, 20, 40, 0.7);
border-radius: 50%;
filter: blur(10px);
}
@keyframes float {
0%, 100% { transform: translateY(0); }
50% { transform: translateY(-15px); }
}
/* 响应式设计 */
@media (max-width: 768px) {
header h1 {
font-size: 2.5rem;
}
.subtitle {
font-size: 1.2rem;
}
#answer {
font-size: 2rem;
}
.btn {
padding: 12px 30px;
font-size: 1.2rem;
}
}
</style>
<div class="container">
<header>
<h1>范范占卜</h1>
<p class="subtitle">静心默念问题,点【获取答案】</p>
</header>
<div class="crystal-ball"></div>
<div class="answer-container">
<div id="answer">你的答案将在这里显示...</div>
</div>
<button class="btn" id="generateBtn">获取答案</button>
<footer>
<div>微信: FanX414</div>
<div class="wechat-note">【加好友占卜】</div>
</footer>
</div>
<script>
// 创建星空背景 [7](@ref)
function createStars() {
const starsContainer = document.getElementById('stars');
const starCount = 150;
for (let i = 0; i < starCount; i++) {
const star = document.createElement('div');
star.classList.add('star');
// 随机大小和位置
const size = Math.random() * 3;
star.style.width = `${size}px`;
star.style.height = `${size}px`;
star.style.left = `${Math.random() * 100}%`;
star.style.top = `${Math.random() * 100}%`;
// 随机动画延迟
star.style.animationDelay = `${Math.random() * 5}s`;
starsContainer.appendChild(star);
}
}
// 答案之书内容 [1,3](@ref)
const answers = [
"是的,毫无疑问。",
"不,现在不是时候。",
"或许,再等等看。",
"相信你的直觉。",
"机会很大,但需努力。",
"保持耐心,好事将至。",
"改变你的视角。",
"跟随你的心。",
"答案在你心中。",
"未来一片光明。",
"谨慎行事。",
"是的,但需要行动。",
"不,避免风险。",
"可能性很高。",
"需要更多信息。",
"顺其自然。",
"会有惊喜。",
"专注当下。",
"放手一搏。",
"结果会超出预期。",
"寻求他人建议。",
"信任这个过程。",
"一切都会好起来。",
"保持积极心态。",
"时机已成熟。",
"重新考虑你的选择。",
"答案即将揭晓。",
"跟随命运的指引。",
"小小冒险会带来回报。",
"倾听内心的声音。"
];
// 随机答案生成函数 [1](@ref)
function generateRandomAnswer() {
const randomIndex = Math.floor(Math.random() * answers.length);
return answers[randomIndex];
}
// 按钮点击事件 [1](@ref)
document.getElementById('generateBtn').addEventListener('click', function() {
const answerElement = document.getElementById('answer');
// 添加一些动画效果
answerElement.style.opacity = '0';
answerElement.style.transform = 'scale(0.8)';
setTimeout(() => {
const randomAnswer = generateRandomAnswer();
answerElement.textContent = randomAnswer;
answerElement.style.opacity = '1';
answerElement.style.transform = 'scale(1)';
}, 300);
});
// 初始化
window.onload = function() {
createStars();
};
</script>