From e2199cfe5a6872b3814dbfb08bed9e7ff1948b20 Mon Sep 17 00:00:00 2001 From: mxr612 Date: Sun, 9 Mar 2025 09:53:06 +0000 Subject: [PATCH] =?UTF-8?q?=E5=AF=BC=E8=88=AA=E6=A0=8F=E9=80=82=E9=85=8D?= =?UTF-8?q?=E4=BA=86=E7=A7=BB=E5=8A=A8=E8=AE=BE=E5=A4=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- static/styles.css | 123 +++++++++++++++++++++++++++----------------- templates/base.html | 3 +- 2 files changed, 77 insertions(+), 49 deletions(-) diff --git a/static/styles.css b/static/styles.css index 1130fbe..a3993d8 100644 --- a/static/styles.css +++ b/static/styles.css @@ -10,6 +10,59 @@ body { align-items: center; /* 确保 body 至少占据整个视口的高度 */ min-height: 100vh; + margin: 0; + padding-top: 80px; + /* 增加顶部内边距避免内容被导航栏遮挡 */ + min-height: calc(100vh - 80px); + /* 补偿导航栏高度 */ +} + + +/* 导航栏样式 */ +nav { + position: fixed; + top: 0; + left: 0; + right: 0; + background-color: #f8f9fa; + padding: 1rem 2rem; + box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); + display: flex; + justify-content: space-between; + align-items: center; + + .nav-left .logo { + font-weight: 700; + font-size: 1.5rem; + color: #2c3e50; + text-decoration: none; + } + + .nav-links { + display: flex; + gap: 2rem; + list-style: none; + margin: 0; + padding: 0; + } + + .nav-links a { + text-decoration: none; + color: #34495e; + font-weight: 500; + transition: color 0.3s ease; + } + + .nav-links a:hover { + color: #3498db; + } + + .menu-toggle { + display: none; + cursor: pointer; + padding: 10px 15px; + font-size: 24px; + } } main { @@ -26,6 +79,28 @@ main { } @media (max-width: 768px) { + nav { + .menu-toggle { + display: block; + } + + .nav-links { + display: none; + position: absolute; + top: 100%; + left: 0; + right: 0; + background: #ffffff; + box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2); + flex-direction: column; + padding: 10px; + } + + .nav-links.active { + display: flex; + } + } + main { width: 95%; /* 全屏展示 */ @@ -65,52 +140,4 @@ main { border-radius: 4px; cursor: pointer; } -} - -/* 导航栏样式 */ -nav { - position: fixed; - top: 0; - left: 0; - right: 0; - background-color: #f8f9fa; - padding: 1rem 2rem; - box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); - display: flex; - justify-content: space-between; - align-items: center; -} - -.nav-left .logo { - font-weight: 700; - font-size: 1.5rem; - color: #2c3e50; - text-decoration: none; -} - -.nav-links { - display: flex; - gap: 2rem; - list-style: none; - margin: 0; - padding: 0; -} - -.nav-links a { - text-decoration: none; - color: #34495e; - font-weight: 500; - transition: color 0.3s ease; -} - -.nav-links a:hover { - color: #3498db; -} - -body { - margin: 0; - padding-top: 80px; - /* 增加顶部内边距避免内容被导航栏遮挡 */ - min-height: calc(100vh - 80px); - /* 补偿导航栏高度 */ } \ No newline at end of file diff --git a/templates/base.html b/templates/base.html index dba93c5..7f4766d 100644 --- a/templates/base.html +++ b/templates/base.html @@ -20,10 +20,11 @@ +