| <?php |
| |
| |
| |
| date_default_timezone_set('Asia/Shanghai'); |
| $currentDateTime = date('Y年m月d日 H:i:s'); |
| $pageTitle = "精美动态网页示例"; |
| $welcomeMessage = "欢迎来到我们的动态展示页面!"; |
|
|
| |
| $randomNumber = rand(1, 100); |
| $dynamicContent = "今天您的幸运数字是:<strong>" . $randomNumber . "</strong>。"; |
|
|
| |
| |
| |
| ?> |
| <!DOCTYPE html> |
| <html lang="zh-CN"> |
| <head> |
| <meta charset="UTF-8"> |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> |
| <title><?php echo htmlspecialchars($pageTitle); ?></title> |
| <link href="https://fonts.googleapis.com/css2?family=Noto+Sans+SC:wght@300;400;700&display=swap" rel="stylesheet"> |
| <style> |
| |
| :root { |
| --primary-color: |
| --secondary-color: |
| --text-color: |
| --bg-light: |
| --bg-dark: |
| --shadow: 0 4px 15px rgba(0, 0, 0, 0.1); |
| --border-radius: 10px; |
| } |
|
|
| body { |
| font-family: 'Noto Sans SC', sans-serif; |
| margin: 0; |
| padding: 0; |
| background: linear-gradient(135deg, var(--bg-light) 0%, var(--bg-dark) 100%); |
| color: var(--text-color); |
| line-height: 1.6; |
| min-height: 100vh; |
| display: flex; |
| flex-direction: column; |
| justify-content: center; |
| align-items: center; |
| overflow-x: hidden; |
| opacity: 0; |
| transition: opacity 1s ease-in-out; |
| } |
|
|
| body.loaded { |
| opacity: 1; |
| } |
|
|
| .container { |
| max-width: 900px; |
| width: 90%; |
| background-color: |
| padding: 40px; |
| border-radius: var(--border-radius); |
| box-shadow: var(--shadow); |
| text-align: center; |
| animation: fadeInScale 1s ease-out forwards; |
| position: relative; |
| z-index: 1; |
| margin: 20px 0; |
| } |
|
|
| @keyframes fadeInScale { |
| from { |
| opacity: 0; |
| transform: scale(0.95) translateY(20px); |
| } |
| to { |
| opacity: 1; |
| transform: scale(1) translateY(0); |
| } |
| } |
|
|
| header h1 { |
| color: var(--primary-color); |
| margin-bottom: 20px; |
| font-size: 2.5em; |
| position: relative; |
| display: inline-block; |
| } |
|
|
| header h1::after { |
| content: ''; |
| position: absolute; |
| left: 50%; |
| bottom: -10px; |
| transform: translateX(-50%); |
| width: 80px; |
| height: 4px; |
| background: linear-gradient(90deg, var(--primary-color), var(--secondary-color)); |
| border-radius: 2px; |
| } |
|
|
| .message { |
| font-size: 1.2em; |
| color: |
| margin-bottom: 30px; |
| } |
|
|
| .card-grid { |
| display: grid; |
| grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); |
| gap: 25px; |
| margin-top: 40px; |
| } |
|
|
| .card { |
| background: var(--bg-light); |
| padding: 25px; |
| border-radius: var(--border-radius); |
| box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05); |
| transition: transform 0.3s ease, box-shadow 0.3s ease; |
| text-align: left; |
| position: relative; |
| overflow: hidden; |
| } |
|
|
|
|
|
|
| .card::before { |
| content: ''; |
| position: absolute; |
| top: 0; |
| left: 0; |
| width: 100%; |
| height: 5px; |
| background: linear-gradient(90deg, var(--primary-color), var(--secondary-color)); |
| transform: translateX(-100%); |
| transition: transform 0.3s ease-out; |
| } |
|
|
| .card:hover::before { |
| transform: translateX(0%); |
| } |
|
|
| .card:hover { |
| transform: translateY(-8px); |
| box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15); |
| } |
|
|
| .card h3 { |
| color: var(--secondary-color); |
| margin-top: 0; |
| font-size: 1.5em; |
| margin-bottom: 15px; |
| } |
|
|
| .card p { |
| color: |
| font-size: 0.95em; |
| } |
|
|
| .footer { |
| margin-top: 40px; |
| font-size: 0.85em; |
| color: |
| padding-top: 20px; |
| border-top: 1px solid |
| } |
|
|
| |
| @media (max-width: 768px) { |
| .container { |
| padding: 25px; |
| width: 95%; |
| } |
| header h1 { |
| font-size: 2em; |
| } |
| .message { |
| font-size: 1em; |
| } |
| .card-grid { |
| grid-template-columns: 1fr; |
| } |
| } |
|
|
| |
| .decoration-blob-1, .decoration-blob-2 { |
| position: absolute; |
| background: linear-gradient(135deg, rgba(106, 17, 203, 0.1), rgba(37, 117, 252, 0.1)); |
| border-radius: 50%; |
| filter: blur(80px); |
| z-index: 0; |
| } |
|
|
| .decoration-blob-1 { |
| width: 300px; |
| height: 300px; |
| top: -100px; |
| left: -100px; |
| animation: floatBlob 10s infinite ease-in-out alternate; |
| } |
|
|
| .decoration-blob-2 { |
| width: 400px; |
| height: 400px; |
| bottom: -150px; |
| right: -150px; |
| animation: floatBlob 12s infinite ease-in-out alternate-reverse; |
| } |
|
|
| @keyframes floatBlob { |
| 0% { transform: translate(0, 0) scale(1); } |
| 50% { transform: translate(30px, -30px) scale(1.05); } |
| 100% { transform: translate(0, 0) scale(1); } |
| } |
|
|
| </style> |
| </head> |
| <body class="loaded"> |
| <div class="decoration-blob-1"></div> |
| <div class="decoration-blob-2"></div> |
| |
| <div class="container"> |
| <header> |
| <h1><?php echo htmlspecialchars($pageTitle); ?></h1> |
| <p class="message"><?php echo htmlspecialchars($welcomeMessage); ?></p> |
| </header> |
| |
| <main> |
| <section class="dynamic-info"> |
| <p>当前时间:<span id="current-time"><?php echo htmlspecialchars($currentDateTime); ?></span></p> |
| <p><?php echo $dynamicContent; ?></p> |
| </section> |
| |
| <section class="card-grid"> |
| <div class="card"> |
| <h3>动态内容渲染</h3> |
| <p>此卡片内容由 PHP 动态生成,展示了服务器端语言如何为页面提供数据。例如,上方的时间和幸运数字。</p> |
| </div> |
| <div class="card"> |
| <h3>响应式设计</h3> |
| <p>页面布局会根据您的设备屏幕尺寸自动调整,在手机、平板和桌面电脑上都能提供良好的浏览体验。</p> |
| </div> |
| <div class="card"> |
| <h3>CSS 动画与交互</h3> |
| <p>鼠标悬停在卡片上或页面加载时,您会看到微妙的动画效果,提升用户体验的趣味性。</p> |
| </div> |
| </section> |
| </main> |
| |
| |
| |
| <footer class="footer"> |
| <p>© <?php echo date('Y'); ?> 动态展示页面. 版权所有。</p> |
| <p>感谢您的访问!</p> |
| </footer> |
| </div> |
| |
| <!-- JavaScript 代码部分 --> |
| <script> |
| document.addEventListener('DOMContentLoaded', function() { |
| |
| |
| function updateTime() { |
| const timeElement = document.getElementById('current-time'); |
| if (timeElement) { |
| const now = new Date(); |
| const options = { |
| year: 'numeric', month: 'numeric', day: 'numeric', |
| hour: '2-digit', minute: '2-digit', second: '2-digit', |
| hour12: false |
| }; |
| timeElement.textContent = now.toLocaleString('zh-CN', options).replace(/\//g, '年').replace(/ /g, '日 ').replace(/,/g, ''); |
| } |
| } |
|
|
| |
| setInterval(updateTime, 1000); |
|
|
| |
| document.body.classList.add('loaded'); |
|
|
| |
| document.querySelectorAll('.card').forEach(card => { |
| card.addEventListener('click', function() { |
| alert('您点击了卡片: ' + this.querySelector('h3').textContent); |
| }); |
| }); |
| }); |
| </script> |
| </body> |
| </html> |
|
|