12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- <!DOCTYPE html>
- <html lang="zh-CN">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>底部导航栏</title>
- <!-- 自定义样式 -->
- <link rel="stylesheet" href="../css/custom.css">
- <!-- FontAwesome -->
- <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
- <style>
- .nav-bar {
- position: fixed;
- bottom: 0;
- left: 0;
- right: 0;
- background-color: white;
- border-top: 1px solid #eee;
- display: flex;
- justify-content: space-around;
- padding: 10px 0;
- box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
- z-index: 100;
- }
-
- .nav-item {
- display: flex;
- flex-direction: column;
- align-items: center;
- color: #888;
- font-size: 10px;
- transition: color 0.2s;
- }
-
- .nav-item.active {
- color: var(--color-primary);
- }
-
- .nav-item i {
- font-size: 22px;
- margin-bottom: 2px;
- }
- </style>
- </head>
- <body>
- <div class="nav-bar">
- <a href="../pages/game-plaza.html" class="nav-item" id="nav-plaza">
- <i class="fas fa-gamepad"></i>
- <span>游戏广场</span>
- </a>
- <a href="../pages/room-join.html" class="nav-item" id="nav-room">
- <i class="fas fa-door-open"></i>
- <span>我的房间</span>
- </a>
- <a href="../pages/game-history.html" class="nav-item" id="nav-history">
- <i class="fas fa-history"></i>
- <span>游戏历史</span>
- </a>
- <a href="../pages/profile.html" class="nav-item" id="nav-profile">
- <i class="fas fa-user"></i>
- <span>我的</span>
- </a>
- </div>
-
- <script>
- document.addEventListener("DOMContentLoaded", function() {
- // 获取当前页面路径
- let currentPath = window.parent.location.pathname;
-
- // 匹配路径并设置对应的导航项为活跃状态
- if (currentPath.includes('game-plaza')) {
- document.getElementById('nav-plaza').classList.add('active');
- } else if (currentPath.includes('room-join') || currentPath.includes('room-waiting') || currentPath.includes('room-create')) {
- document.getElementById('nav-room').classList.add('active');
- } else if (currentPath.includes('game-history')) {
- document.getElementById('nav-history').classList.add('active');
- } else if (currentPath.includes('profile')) {
- document.getElementById('nav-profile').classList.add('active');
- } else if (currentPath.includes('game-turtle')) {
- // 游戏页面不高亮导航栏中的任何选项
- } else {
- // 默认选中游戏广场
- document.getElementById('nav-plaza').classList.add('active');
- }
- });
- </script>
- </body>
- </html>
|