找回密码
 注册
搜索
免费空间 免费域名 免费AI 老牌主机商首月仅1美分!27美元/年!Namecheap优惠码Spaceship优惠码
楼主: inoking

[问题求助] 有没有好看的PHP版个人网站导航,带后台管理的

[复制链接]
 楼主| 发表于 7 天前 | 显示全部楼层
yaner 发表于 2025-3-22 11:26
好吧,来个极简的,没有后台。
https://hu.xd94.com/link/scyx_g.php

代码分享下
发表于 7 天前 | 显示全部楼层
本帖最后由 yaner 于 2025-3-23 00:04 编辑

  1. <!DOCTYPE html>
  2. <html lang="zh-CN">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <title>悬停切换导航</title>
  7. <base target="_blank">
  8. <style>
  9. :root {
  10. --primary-color: #004a9b;
  11. --active-color: #e60012;
  12. --button-bg: #1e90ff;
  13. --button-hover: #1c75d8;
  14. --sidebar-width: 250px;
  15. }
  16. * { margin: 0; padding: 0; box-sizing: border-box; }
  17. .tab-container {
  18. max-width: 800px;
  19. margin: 20px auto;
  20. background: #fff;
  21. box-shadow: 0 2px 12px rgba(0,0,0,0.1);
  22. border-radius: 8px;
  23. display: flex;
  24. height: 600px;
  25. }
  26. .tab-nav {
  27. width: var(--sidebar-width);
  28. background: #f8f8f8;
  29. border-right: 2px solid #eee;
  30. border-radius: 8px 0 0 8px;
  31. padding: 20px 0;
  32. }
  33. .tab-trigger {
  34. padding: 15px 20px;
  35. font-size: 17px;
  36. color: #666;
  37. cursor: pointer;
  38. transition: all 0.3s;
  39. }
  40. .tab-trigger:hover,
  41. .tab-trigger.active {
  42. color: var(--active-color);
  43. background: #e0e0e0;
  44. }
  45. .tab-content {
  46. flex: 1;
  47. padding: 30px;
  48. overflow-y: auto;
  49. }
  50. .content-pane {
  51. display: none;
  52. animation: fadeIn 0.4s ease-out;
  53. }
  54. .content-pane.active {
  55. display: block;
  56. }
  57. ul { list-style: none; }
  58. .nav-button {
  59. display: block;
  60. width: 100%;
  61. max-width: 400px;
  62. height: 50px;
  63. margin: 10px 0;
  64. background: var(--button-bg);
  65. color: white;
  66. font-size: 16px;
  67. text-align: center;
  68. line-height: 50px;
  69. border-radius: 8px;
  70. text-decoration: none;
  71. transition: background 0.3s ease;
  72. box-shadow: inset 0 0 10px rgba(0,0,0,0.2);
  73. }
  74. .nav-button:hover {
  75. background: var(--button-hover);
  76. }
  77. @keyframes fadeIn {
  78. from { opacity: 0; transform: translateY(10px); }
  79. to { opacity: 1; transform: translateY(0); }
  80. }
  81. </style>
  82. </head>
  83. <body>
  84. <?php
  85. // 读取菜单数据文件
  86. $menu_data = [];
  87. $current_category = '';
  88. $file_path = 'website.txt';
  89. if (file_exists($file_path)) {
  90. $lines = file($file_path, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
  91. foreach ($lines as $line) {
  92. $line = trim($line);
  93. if (strpos($line, ',') === false) {
  94. $current_category = $line;
  95. $menu_data[$current_category] = [];
  96. } else {
  97. [$title, $link, $desc] = array_pad(explode(',', $line, 3), 3, '');
  98. $menu_data[$current_category][] = [
  99. 'title' => trim($title),
  100. 'link' => trim($link),
  101. 'desc' => trim($desc)
  102. ];
  103. }
  104. }
  105. }
  106. $categories = array_keys($menu_data);
  107. ?>
  108. <div class="tab-container">
  109. <nav class="tab-nav">
  110. <?php foreach ($categories as $i => $category): ?>
  111. <div class="tab-trigger <?= $i === 0 ? 'active' : '' ?>" onmouseover="switchTab('cat<?= $i ?>')"><?= htmlspecialchars($category) ?></div>
  112. <?php endforeach; ?>
  113. </nav>
  114. <div class="tab-content">
  115. <?php foreach ($categories as $i => $category): ?>
  116. <div id="cat<?= $i ?>" class="content-pane <?= $i === 0 ? 'active' : '' ?>">
  117. <ul>
  118. <?php foreach ($menu_data[$category] as $item): ?>
  119. <li><a href="<?= htmlspecialchars($item['link']) ?>" class="nav-button" title="<?= htmlspecialchars($item['desc']) ?>"><?= htmlspecialchars($item['title']) ?></a></li>
  120. <?php endforeach; ?>
  121. </ul>
  122. </div>
  123. <?php endforeach; ?>
  124. </div>
  125. </div>
  126. <script>
  127. function switchTab(tabId) {
  128. document.querySelectorAll('.tab-trigger').forEach(t => t.classList.remove('active'));
  129. document.querySelectorAll('.content-pane').forEach(p => p.classList.remove('active'));
  130. event.target.classList.add('active');
  131. document.getElementById(tabId).classList.add('active');
  132. }
  133. </script>
  134. </body>
  135. </html>
复制代码

web.php

  1. <!DOCTYPE html>
  2. <html lang="zh-CN">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <title>悬停切换导航</title>
  7. <base target="_blank">
  8. <style>
  9. :root {
  10. --primary-color: #004a9b;
  11. --active-color: #e60012;
  12. --button-bg: #1e90ff;
  13. --button-hover: #1c75d8;
  14. --sidebar-width: 250px;
  15. }
  16. * { margin: 0; padding: 0; box-sizing: border-box; }
  17. .tab-container {
  18. max-width: 800px;
  19. margin: 20px auto;
  20. background: #fff;
  21. box-shadow: 0 2px 12px rgba(0,0,0,0.1);
  22. border-radius: 8px;
  23. display: flex;
  24. height: 600px;
  25. }
  26. .tab-nav {
  27. width: var(--sidebar-width);
  28. background: #f8f8f8;
  29. border-right: 2px solid #eee;
  30. border-radius: 8px 0 0 8px;
  31. padding: 20px 0;
  32. }
  33. .tab-trigger {
  34. padding: 15px 20px;
  35. font-size: 17px;
  36. color: #666;
  37. cursor: pointer;
  38. transition: all 0.3s;
  39. }
  40. .tab-trigger:hover,
  41. .tab-trigger.active {
  42. color: var(--active-color);
  43. background: #e0e0e0;
  44. }
  45. .tab-content {
  46. flex: 1;
  47. padding: 30px;
  48. overflow-y: auto;
  49. }
  50. .content-pane {
  51. display: none;
  52. animation: fadeIn 0.4s ease-out;
  53. }
  54. .content-pane.active {
  55. display: block;
  56. }
  57. ul { list-style: none; }
  58. .nav-button {
  59. display: block;
  60. width: 100%;
  61. max-width: 400px;
  62. height: 50px;
  63. margin: 10px 0;
  64. background: var(--button-bg);
  65. color: white;
  66. font-size: 16px;
  67. text-align: center;
  68. line-height: 50px;
  69. border-radius: 8px;
  70. text-decoration: none;
  71. transition: background 0.3s ease;
  72. box-shadow: inset 0 0 10px rgba(0,0,0,0.2);
  73. }
  74. .nav-button:hover {
  75. background: var(--button-hover);
  76. }
  77. @keyframes fadeIn {
  78. from { opacity: 0; transform: translateY(10px); }
  79. to { opacity: 1; transform: translateY(0); }
  80. }
  81. /* 分类标题样式 */
  82. .category-title {
  83. font-size: 20px;
  84. color: var(--primary-color);
  85. margin-bottom: 15px;
  86. padding-bottom: 5px;
  87. border-bottom: 2px solid #eee;
  88. display: none; /* 默认隐藏 */
  89. }
  90. /* 移动端样式 */
  91. @media screen and (max-width: 768px) {
  92. .tab-container {
  93. display: block;
  94. height: auto;
  95. padding: 20px;
  96. }

  97. .tab-nav {
  98. display: none; /* 隐藏侧边栏 */
  99. }

  100. .tab-content {
  101. padding: 0;
  102. }

  103. .content-pane {
  104. display: block; /* 全部显示 */
  105. margin-bottom: 30px;
  106. }

  107. .content-pane.active {
  108. display: block;
  109. }

  110. .category-title {
  111. text-align: center;
  112. display: block; /* 移动端显示标题 */
  113. }

  114. .nav-button {
  115. max-width: 100%;
  116. }
  117. }
  118. /* 桌面端确保标题隐藏 */
  119. @media screen and (min-width: 769px) {
  120. .category-title {
  121. display: none !important; /* 强制隐藏标题 */
  122. }
  123. }
  124. </style>
  125. </head>
  126. <body>
  127. <?php
  128. // 读取菜单数据文件
  129. $menu_data = [];
  130. $current_category = '';
  131. $file_path = 'website.txt';
  132. if (file_exists($file_path)) {
  133. $lines = file($file_path, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
  134. foreach ($lines as $line) {
  135. $line = trim($line);
  136. if (strpos($line, ',') === false) {
  137. $current_category = $line;
  138. $menu_data[$current_category] = [];
  139. } else {
  140. [$title, $link, $desc] = array_pad(explode(',', $line, 3), 3, '');
  141. $menu_data[$current_category][] = [
  142. 'title' => trim($title),
  143. 'link' => trim($link),
  144. 'desc' => trim($desc)
  145. ];
  146. }
  147. }
  148. }
  149. $categories = array_keys($menu_data);
  150. ?>
  151. <div class="tab-container">
  152. <nav class="tab-nav">
  153. <?php foreach ($categories as $i => $category): ?>
  154. <div class="tab-trigger <?= $i === 0 ? 'active' : '' ?>" onmouseover="switchTab('cat<?= $i ?>')"><?= htmlspecialchars($category) ?></div>
  155. <?php endforeach; ?>
  156. </nav>
  157. <div class="tab-content">
  158. <?php foreach ($categories as $i => $category): ?>
  159. <div id="cat<?= $i ?>" class="content-pane <?= $i === 0 ? 'active' : '' ?>">
  160. <h2 class="category-title"><?= htmlspecialchars($category) ?></h2>
  161. <ul>
  162. <?php foreach ($menu_data[$category] as $item): ?>
  163. <li><a href="<?= htmlspecialchars($item['link']) ?>" class="nav-button" title="<?= htmlspecialchars($item['desc']) ?>"><?= htmlspecialchars($item['title']) ?></a></li>
  164. <?php endforeach; ?>
  165. </ul>
  166. </div>
  167. <?php endforeach; ?>
  168. </div>
  169. </div>
  170. <script>
  171. function switchTab(tabId) {
  172. document.querySelectorAll('.tab-trigger').forEach(t => t.classList.remove('active'));
  173. document.querySelectorAll('.content-pane').forEach(p => p.classList.remove('active'));
  174. event.target.classList.add('active');
  175. document.getElementById(tabId).classList.add('active');
  176. }
  177. // 在移动端不需要切换功能,所以只在桌面端启用
  178. if (window.innerWidth > 768) {
  179. document.querySelectorAll('.tab-trigger').forEach(trigger => {
  180. trigger.addEventListener('mouseover', function(e) {
  181. switchTab(e.target.getAttribute('onmouseover').match(/'([^']+)'/)[1]);
  182. });
  183. });
  184. }
  185. </script>
  186. </body>
  187. </html>
复制代码
web.php 兼顾移动端显示

  1. 省教育厅
  2. 职业教育高质量发展新举措,/edu/policy.html,2025年全省教育工作部署
  3. 教师帮培计划进展,/edu/training.html,首批300名教师培训完成
  4. 校园食品安全专项,/edu/food-safety.html,抽检合格率98.7%
  5. 省经信厅
  6. 工业增加值数据,/economy/growth.html,同比增长6.8%
  7. 轻工认证中心,/economy/certification.html,新增国家级认证中心2个
  8. 盐化工升级规划,/economy/upgrade.html,2025年智能化生产线规划
  9. 今日盐校
  10. 新校区建设进度,/school/campus.html,2025年9月投入使用计划
  11. 毕业生就业数据,/school/employment.html,盐业相关专业就业率100%
  12. 跨省教学合作,/school/cooperation.html,与江西陶瓷工艺美院共建基地
  13. 留言
  14. 留言本,https://gb.gwxy.net,拐翁小院留言本
  15. 其它
  16. 维兰网,https://site.xd94.com,维兰网2023版
复制代码
website.txt
发表于 7 天前 | 显示全部楼层

弄了一个玩玩,感谢


http://5fm.dpdns.org/
 楼主| 发表于 7 天前 来自手机 | 显示全部楼层
yaner 发表于 2025-3-22 13:17
web.php



真心不错
发表于 5 天前 | 显示全部楼层
https://365.de.cool
无后台导航,
缺点:不支持手机自适应。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|小黑屋|免费吧论坛

GMT+8, 2025-3-29 07:20 , Processed in 0.020372 second(s), 3 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表