/* ==================== 全局样式 ==================== */ * { margin: 0; padding: 0; box-sizing: border-box; } :root { --primary-color: #0969da; --primary-hover: #0550ae; --bg-color: #ffffff; --text-color: #24292f; --border-color: #d0d7de; --sidebar-bg: #f6f8fa; --hover-bg: #f3f4f6; --shadow: 0 2px 8px rgba(0, 0, 0, 0.1); --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.1); } body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"; line-height: 1.6; color: var(--text-color); background-color: var(--bg-color); } /* ==================== 首页样式 ==================== */ .container { max-width: 1200px; margin: 0 auto; padding: 20px; } .header { text-align: center; padding: 40px 20px; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white; border-radius: 12px; margin-bottom: 40px; box-shadow: var(--shadow-lg); } .title { font-size: 2.5rem; font-weight: 700; margin-bottom: 8px; } .subtitle { font-size: 1rem; opacity: 0.9; } .main-content { min-height: 400px; } .categories-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 24px; margin-top: 30px; } .category-card { background: white; border: 1px solid var(--border-color); border-radius: 12px; padding: 24px; transition: all 0.3s ease; box-shadow: var(--shadow); } .category-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); border-color: var(--primary-color); } .category-title { font-size: 1.8rem; color: var(--primary-color); margin-bottom: 12px; font-weight: 600; } .doc-count { color: #656d76; margin-bottom: 16px; font-size: 0.95rem; } .read-btn { width: 100%; padding: 12px 24px; background: var(--primary-color); color: white; border: none; border-radius: 8px; font-size: 1rem; font-weight: 600; cursor: pointer; transition: background 0.3s ease; margin-top: 16px; } .read-btn:hover { background: var(--primary-hover); } /* ==================== 阅读页样式 ==================== */ .reader-container { display: flex; min-height: 100vh; } .sidebar { background: var(--sidebar-bg); border-right: 1px solid var(--border-color); overflow-y: auto; transition: transform 0.3s ease; position: fixed; top: 0; height: 100vh; } .left-sidebar { width: 280px; min-width: 280px; left: 0; } .right-sidebar { width: 260px; min-width: 260px; border-right: none; right: 0; background: white; } .sidebar-header { padding: 20px; border-bottom: 1px solid var(--border-color); background: white; position: sticky; top: 0; z-index: 10; } .sidebar-header h2, .sidebar-header h3 { font-size: 1.1rem; color: var(--text-color); font-weight: 600; display: flex; align-items: center; justify-content: space-between; } .header-icons { display: flex; gap: 8px; align-items: center; } .icon-btn { font-size: 1.2rem; background: none; border: none; cursor: pointer; transition: transform 0.3s ease; padding: 4px; text-decoration: none; } .icon-btn:hover { transform: scale(1.2); } .content-area { flex: 1; padding: 40px; background: white; position: relative; margin-left: 280px; margin-right: 260px; min-height: 100vh; } /* ==================== 搜索功能样式 ==================== */ .search-container { position: sticky; top: 0; z-index: 100; background: white; padding-bottom: 20px; margin-bottom: 20px; border-bottom: 1px solid var(--border-color); display: none; animation: slideDown 0.3s ease-out; } .search-container.active { display: block; } @keyframes slideDown { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } } .search-box { display: flex; align-items: center; gap: 8px; max-width: 600px; } #search-input { flex: 1; padding: 10px 16px; border: 2px solid var(--border-color); border-radius: 8px; font-size: 0.95rem; transition: border-color 0.3s; } #search-input:focus { outline: none; border-color: var(--primary-color); } .search-icon-btn { padding: 10px 16px; background: var(--primary-color); color: white; border: none; border-radius: 8px; font-size: 1.2rem; cursor: pointer; transition: background 0.3s; } .search-icon-btn:hover { background: var(--primary-hover); } .close-search-box-btn { padding: 8px 12px; background: none; color: #656d76; border: none; font-size: 2rem; line-height: 1; cursor: pointer; transition: all 0.3s; border-radius: 6px; } .close-search-box-btn:hover { background: rgba(0, 0, 0, 0.05); color: var(--text-color); } /* 搜索结果浮层 */ .search-results { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); width: calc(100% - 80px); max-width: 900px; max-height: 80vh; background: white; border: 1px solid var(--border-color); border-radius: 12px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3); z-index: 1000; overflow: hidden; } /* 搜索结果背景遮罩 */ .search-results::before { content: ''; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0, 0, 0, 0.5); z-index: -1; } .search-results-header { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border-color); background: var(--sidebar-bg); } .search-results-title { font-weight: 600; font-size: 1.1rem; color: var(--text-color); } .search-results-content { max-height: calc(70vh - 60px); overflow-y: auto; padding: 20px; } .results-section { margin-bottom: 24px; } .results-section:last-child { margin-bottom: 0; } .results-section-title { font-size: 1rem; font-weight: 600; color: var(--text-color); margin-bottom: 12px; padding-bottom: 8px; border-bottom: 2px solid var(--primary-color); } .results-list { display: flex; flex-direction: column; gap: 12px; } .search-result-item { background: var(--sidebar-bg); border: 1px solid var(--border-color); border-radius: 8px; padding: 12px; transition: all 0.2s; } .search-result-item:hover { border-color: var(--primary-color); box-shadow: var(--shadow); } .result-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; } .result-doc-name { font-weight: 600; color: var(--primary-color); font-size: 0.95rem; } .result-count { font-size: 0.85rem; color: #656d76; background: white; padding: 2px 8px; border-radius: 12px; } .result-match { padding: 8px; background: white; border-left: 3px solid var(--primary-color); border-radius: 4px; margin-top: 8px; cursor: pointer; transition: all 0.2s; } .result-match:hover { background: rgba(9, 105, 218, 0.05); transform: translateX(4px); } .match-line-number { font-size: 0.8rem; color: #656d76; margin-bottom: 4px; } .match-snippet { font-size: 0.9rem; line-height: 1.5; color: var(--text-color); } .search-highlight { background: #fff3cd; color: #856404; padding: 2px 4px; border-radius: 3px; font-weight: 600; } .no-results { text-align: center; padding: 20px; color: #656d76; font-style: italic; } /* 搜索结果空状态样式 */ .empty-search-state { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 60px 20px; text-align: center; animation: fadeIn 0.3s ease; } @keyframes fadeIn { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } } .empty-icon { margin-bottom: 24px; color: #8b949e; opacity: 0.6; } .empty-icon svg { width: 64px; height: 64px; } .empty-title { font-size: 1.2rem; font-weight: 600; color: var(--text-color); margin: 0 0 12px 0; } .empty-text { font-size: 0.95rem; color: #656d76; margin: 0; line-height: 1.5; } /* 临时高亮效果 */ .temp-highlight { animation: highlightFade 2s ease-out; } @keyframes highlightFade { 0% { background-color: #fff3cd; } 100% { background-color: transparent; } } /* 文档导航 */ .doc-nav { padding: 12px; } .nav-item { margin: 4px 0; } .nav-link { display: block; padding: 10px 12px; color: var(--text-color); text-decoration: none; border-radius: 6px; transition: all 0.2s; font-size: 0.95rem; } .nav-link:hover { background: var(--hover-bg); color: var(--primary-color); } .nav-item.active .nav-link { background: var(--primary-color); color: white; font-weight: 600; } .nav-item.level-1 { margin-left: 16px; } .nav-item.level-2 { margin-left: 32px; } /* TOC 样式 - VitePress风格 */ .toc { padding: 16px 16px 16px 16px; position: relative; } /* VitePress风格:左侧竖线 */ .toc::before { content: ''; position: absolute; left: 20px; top: 16px; bottom: 16px; width: 1px; background: var(--border-color); } .toc-link { display: block; padding: 2px 0 2px 14px; color: #6b7280; text-decoration: none; transition: all 0.25s; font-size: 0.8125rem; margin: 0; line-height: 1.5; position: relative; border-left: 1px solid transparent; } .toc-link:hover { color: var(--text-color); } /* VitePress风格:活跃状态的蓝色竖线 */ .toc-link.active { color: var(--primary-color); font-weight: 500; border-left-color: var(--primary-color); } /* 各级标题缩进 - VitePress风格更紧凑 */ .toc-level-1 { padding-left: 14px; font-weight: 500; font-size: 0.8125rem; } .toc-level-2 { padding-left: 24px; font-size: 0.78rem; } .toc-level-3 { padding-left: 34px; font-size: 0.78rem; } .toc-level-4 { padding-left: 44px; font-size: 0.78rem; } .toc-level-5 { padding-left: 54px; font-size: 0.78rem; } .toc-level-6 { padding-left: 64px; font-size: 0.78rem; } .toc-empty { padding: 12px; color: #656d76; font-size: 0.85rem; font-style: italic; text-align: center; } /* 侧边栏切换按钮 */ .toggle-sidebar-btn { display: none; position: fixed; bottom: 20px; background: var(--primary-color); color: white; border: none; border-radius: 50%; width: 48px; height: 48px; font-size: 1.5rem; cursor: pointer; box-shadow: var(--shadow-lg); z-index: 1001; opacity: 0.3; transition: all 0.3s ease; } .toggle-sidebar-btn:hover { opacity: 1; background: var(--primary-hover); transform: scale(1.1); } .toggle-sidebar-btn:active { transform: scale(0.95); } #toggle-left { left: 20px; } #toggle-right { right: 20px; } /* ==================== GitHub 风格 Markdown 样式 ==================== */ .markdown-body { font-size: 16px; line-height: 1.6; word-wrap: break-word; } .markdown-body h1, .markdown-body h2, .markdown-body h3, .markdown-body h4, .markdown-body h5, .markdown-body h6 { margin-top: 24px; margin-bottom: 16px; font-weight: 600; line-height: 1.25; color: var(--text-color); } .markdown-body h1 { font-size: 2em; border-bottom: 1px solid var(--border-color); padding-bottom: 0.3em; } .markdown-body h2 { font-size: 1.5em; border-bottom: 1px solid var(--border-color); padding-bottom: 0.3em; } .markdown-body h3 { font-size: 1.25em; } .markdown-body h4 { font-size: 1em; } .markdown-body h5 { font-size: 0.875em; } .markdown-body h6 { font-size: 0.85em; color: #656d76; } .markdown-body p { margin-top: 0; margin-bottom: 16px; } .markdown-body a { color: var(--primary-color); text-decoration: none; } .markdown-body a:hover { text-decoration: underline; } .markdown-body ul, .markdown-body ol { margin-top: 0; margin-bottom: 16px; padding-left: 2em; } .markdown-body li { margin-top: 0.25em; } .markdown-body blockquote { margin: 0 0 16px 0; padding: 0 1em; color: #656d76; border-left: 0.25em solid var(--border-color); } .markdown-body code { padding: 0.2em 0.4em; margin: 0; font-size: 85%; background-color: rgba(175, 184, 193, 0.2); border-radius: 6px; font-family: ui-monospace, SFMono-Regular, SF Mono, Menlo, Consolas, Liberation Mono, monospace; } .markdown-body pre { margin-top: 0; margin-bottom: 16px; padding: 16px; overflow: auto; font-size: 85%; line-height: 1.45; background-color: #f6f8fa; border-radius: 6px; } .markdown-body pre code { display: block; padding: 0; margin: 0; overflow: visible; line-height: inherit; word-wrap: normal; background-color: transparent; border: 0; } .markdown-body table { border-spacing: 0; border-collapse: collapse; margin-top: 0; margin-bottom: 16px; width: 100%; overflow: auto; } .markdown-body table th, .markdown-body table td { padding: 6px 13px; border: 1px solid var(--border-color); } .markdown-body table th { font-weight: 600; background-color: var(--sidebar-bg); } .markdown-body table tr { background-color: var(--bg-color); border-top: 1px solid var(--border-color); } .markdown-body table tr:nth-child(2n) { background-color: var(--sidebar-bg); } .markdown-body img { max-width: 100%; height: auto; border-radius: 6px; margin: 16px 0; } .markdown-body hr { height: 0.25em; padding: 0; margin: 24px 0; background-color: var(--border-color); border: 0; } /* ==================== 文档导航(上一页/下一页) ==================== */ .doc-navigation { display: flex; justify-content: space-between; gap: 20px; margin-top: 60px; padding: 40px 0; border-top: 2px solid var(--border-color); } .nav-prev, .nav-next { flex: 0 0 calc(50% - 10px); display: flex; flex-direction: column; padding: 20px 24px; background: var(--sidebar-bg); border: 2px solid var(--border-color); border-radius: 12px; cursor: pointer; transition: all 0.3s ease; min-height: 100px; justify-content: center; } .nav-prev:hover, .nav-next:hover { border-color: var(--primary-color); background: white; transform: translateY(-2px); box-shadow: var(--shadow-lg); } .nav-label { font-size: 0.85rem; color: #656d76; font-weight: 500; margin-bottom: 8px; } .nav-prev .nav-label { text-align: left; } .nav-next .nav-label { text-align: right; } .nav-doc-name { font-size: 1.1rem; font-weight: 600; color: var(--text-color); line-height: 1.4; word-wrap: break-word; } .nav-prev .nav-doc-name { text-align: left; } .nav-next .nav-doc-name { text-align: right; } /* 同时有上一页和下一页时,两侧分布 */ .doc-navigation.has-both { justify-content: space-between; } /* 只有下一页时(首页),下一页按钮固定在右侧 */ .doc-navigation.has-next-only { justify-content: flex-end; } /* 只有上一页时(末页),上一页按钮固定在左侧 */ .doc-navigation.has-prev-only { justify-content: flex-start; } /* ==================== 加载和错误状态 ==================== */ .loading { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 60px 20px; color: #656d76; } .spinner { width: 40px; height: 40px; border: 4px solid var(--border-color); border-top-color: var(--primary-color); border-radius: 50%; animation: spin 1s linear infinite; } @keyframes spin { to { transform: rotate(360deg); } } .error, .error-message { padding: 20px; background: #fff1f0; color: #cf222e; border: 1px solid #ffcccb; border-radius: 8px; margin: 20px 0; text-align: center; } /* ==================== 响应式设计 ==================== */ @media (max-width: 1024px) { .right-sidebar { z-index: 100; box-shadow: -2px 0 8px rgba(0, 0, 0, 0.1); } .right-sidebar.collapsed { transform: translateX(100%); } .right-sidebar:not(.collapsed) { transform: translateX(0); } .content-area { padding: 30px; margin-right: 0; } #toggle-right { display: block; } .search-results { width: calc(100% - 60px); } } @media (max-width: 768px) { .title { font-size: 2rem; } .subtitle { font-size: 1rem; } .categories-grid { grid-template-columns: 1fr; gap: 16px; } .left-sidebar { z-index: 100; transform: translateX(-100%); box-shadow: 2px 0 8px rgba(0, 0, 0, 0.1); } .right-sidebar { z-index: 100; box-shadow: -2px 0 8px rgba(0, 0, 0, 0.1); } .content-area { padding: 20px; margin-left: 0; margin-right: 0; width: 100%; } .search-container { padding-bottom: 15px; margin-bottom: 15px; } .search-box { max-width: 100%; } #search-input { font-size: 0.9rem; padding: 8px 12px; } .search-icon-btn { padding: 8px 12px; font-size: 1rem; } .search-results { width: calc(100% - 20px); max-height: 85vh; } .search-results-content { padding: 15px; max-height: calc(80vh - 60px); } .result-match { padding: 6px; } .match-snippet { font-size: 0.85rem; } /* 移动端空状态样式调整 */ .empty-search-state { padding: 40px 20px; } .empty-icon svg { width: 48px; height: 48px; } .empty-title { font-size: 1.1rem; } .empty-text { font-size: 0.9rem; } .toggle-sidebar-btn { display: block; width: 56px; height: 56px; font-size: 1.7rem; box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4); z-index: 1001; } #toggle-left { bottom: 20px; left: 20px; } #toggle-right { bottom: 20px; right: 20px; } /* 侧边栏展开/收起状态 */ .left-sidebar.collapsed { transform: translateX(-100%); } .left-sidebar:not(.collapsed) { transform: translateX(0); } .right-sidebar.collapsed { transform: translateX(100%); } .right-sidebar:not(.collapsed) { transform: translateX(0); } /* 悬浮按钮调整 */ .floating-action-btn { width: 45px; height: 45px; z-index: 1002; opacity: 0.45; } .floating-action-btn:hover { opacity: 1; } .back-to-top { bottom: 100px; right: 20px; } .edit-btn { bottom: 100px; right: 75px; } .editor-header { padding: 15px 20px; } .markdown-body { font-size: 14px; } .markdown-body h1 { font-size: 1.75em; } .markdown-body h2 { font-size: 1.4em; } .markdown-body pre { padding: 12px; font-size: 80%; } /* 文档导航(上一页/下一页)移动端样式 */ .doc-navigation { flex-direction: column; gap: 16px; margin-top: 40px; padding: 30px 0; } /* 移动端垂直布局,始终从上到下排列 */ .doc-navigation.has-next-only, .doc-navigation.has-prev-only { justify-content: flex-start; } .nav-prev, .nav-next { flex: 1 1 auto; min-height: 80px; padding: 16px 20px; } .nav-label { font-size: 0.8rem; } .nav-doc-name { font-size: 1rem; } /* TOC 移动端样式 */ .toc { padding: 12px 12px 12px 12px; } .toc::before { left: 16px; top: 12px; bottom: 12px; } .toc-link { font-size: 0.78rem; padding: 2px 0 2px 12px; line-height: 1.4; } .toc-level-1 { padding-left: 12px; font-size: 0.78rem; } .toc-level-2 { padding-left: 20px; font-size: 0.75rem; } .toc-level-3 { padding-left: 28px; font-size: 0.75rem; } .toc-level-4 { padding-left: 36px; font-size: 0.75rem; } } /* 悬浮操作按钮(通用样式) */ .floating-action-btn { position: fixed; width: 50px; height: 50px; background: var(--primary-color); color: white; border: none; border-radius: 50%; cursor: pointer; display: flex; align-items: center; justify-content: center; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15); opacity: 0.35; transition: all 0.3s ease; z-index: 1002; outline: none; } .floating-action-btn:hover { opacity: 1; transform: translateY(-3px); box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2); } .floating-action-btn:active { transform: translateY(-1px); } .floating-action-btn svg { display: block; } /* 回到顶部按钮 */ .back-to-top { bottom: 40px; right: 40px; } .back-to-top.hidden { opacity: 0; pointer-events: none; } /* 编辑按钮 */ .edit-btn { bottom: 40px; right: 110px; /* 在回到顶部按钮左侧 */ } .edit-btn.hidden { opacity: 0; pointer-events: none; } /* 编辑按钮激活状态 */ .edit-btn.active { opacity: 1; background: #28a745; box-shadow: 0 4px 12px rgba(40, 167, 69, 0.4); } .edit-btn.active:hover { background: #218838; box-shadow: 0 6px 16px rgba(40, 167, 69, 0.5); } /* 编辑器容器 */ .editor-container { position: absolute; top: 0; left: 0; right: 0; bottom: 0; background: white; z-index: 10; display: flex; flex-direction: column; } .editor-header { display: flex; justify-content: space-between; align-items: center; padding: 20px 30px; background: var(--sidebar-bg); border-bottom: 2px solid var(--border-color); } .editor-header h3 { margin: 0; font-size: 1.2rem; color: var(--text-color); } .editor-header h3 span { color: var(--primary-color); font-weight: 600; } .editor-actions { display: flex; gap: 12px; } .editor-action-btn { padding: 10px 20px; border: none; border-radius: 6px; font-size: 0.95rem; font-weight: 600; cursor: pointer; transition: all 0.2s ease; } .save-btn { background: var(--primary-color); color: white; } .save-btn:hover { background: var(--primary-hover); } .cancel-btn { background: #6c757d; color: white; } .cancel-btn:hover { background: #5a6268; } /* Markdown编辑器 */ .markdown-editor { flex: 1; padding: 30px; border: none; outline: none; font-family: ui-monospace, SFMono-Regular, SF Mono, Menlo, Consolas, Liberation Mono, monospace; font-size: 14px; line-height: 1.6; resize: none; background: white; color: var(--text-color); } .markdown-editor::placeholder { color: #656d76; } /* 成功提示动画 */ @keyframes slideInRight { from { opacity: 0; transform: translateX(100px); } to { opacity: 1; transform: translateX(0); } } @keyframes slideOutRight { from { opacity: 1; transform: translateX(0); } to { opacity: 0; transform: translateX(100px); } } /* ==================== 代码复制功能样式 ==================== */ /* 代码块容器 */ .code-block-wrapper { position: relative; margin: 1em 0; } /* 复制按钮 */ .code-copy-btn { position: absolute; top: 8px; right: 8px; background: rgba(255, 255, 255, 0.9); border: 1px solid var(--border-color); border-radius: 6px; padding: 4px 8px; cursor: pointer; font-size: 12px; color: var(--text-color); display: flex; align-items: center; gap: 4px; transition: all 0.2s ease; opacity: 0; z-index: 10; } /* 代码块悬停时显示复制按钮 */ .code-block-wrapper:hover .code-copy-btn { opacity: 1; } .code-copy-btn:hover { background: var(--primary-color); color: white; border-color: var(--primary-color); transform: scale(1.05); } .code-copy-btn:active { transform: scale(0.95); } /* 复制按钮图标 */ .code-copy-btn svg { width: 14px; height: 14px; } /* 复制成功状态 */ .code-copy-btn.copied { background: var(--primary-color); color: white; border-color: var(--primary-color); } /* 确保代码块有正确的样式 */ pre { position: relative; background: #f6f8fa; border-radius: 6px; padding: 16px; overflow-x: auto; margin: 1em 0; } pre code { background: transparent; padding: 0; border-radius: 0; font-size: 14px; line-height: 1.45; } /* ==================== 图片样式优化 ==================== */ .markdown-body img { max-width: 100%; height: auto; border-radius: 6px; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1); margin: 1em 0; display: block; } .markdown-body img:hover { box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15); transform: scale(1.02); transition: all 0.3s ease; } /* 图片加载失败样式 */ .img-error { border: 1px dashed #ccc; padding: 10px; min-height: 100px; display: block; background-color: #f5f5f5; color: #666; text-align: center; line-height: 100px; }