From 23e61ba9667bbffa4e68cde45e6f1d57c1e8b5d8 Mon Sep 17 00:00:00 2001 From: ozh Date: Wed, 9 Sep 2026 14:02:50 +0800 Subject: [PATCH] =?UTF-8?q?fix(ui):=20Navbar=20=E6=A0=87=E9=A2=98=E6=94=B9?= =?UTF-8?q?=20View=20=E5=8C=85=E8=A3=B9=E4=BF=AE=E5=A4=8D=20text=20?= =?UTF-8?q?=E7=BB=9D=E5=AF=B9=E5=AE=9A=E4=BD=8D=E5=AE=BD=E5=BA=A6=E6=94=B6?= =?UTF-8?q?=E7=BC=A9=E5=AF=BC=E8=87=B4=E7=9A=84=E4=B8=8D=E5=B1=85=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/navbar/index.module.scss | 7 ++++++- src/components/navbar/index.tsx | 5 ++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/components/navbar/index.module.scss b/src/components/navbar/index.module.scss index 0db7bc8..cede87d 100644 --- a/src/components/navbar/index.module.scss +++ b/src/components/navbar/index.module.scss @@ -28,11 +28,16 @@ } // 绝对定位居中:与 back 按钮是否存在无关,免手动平衡宽度 -.title { +// 外层必须是 View(block 元素):text 标签在 absolute 下宽度收缩、 +// left+right 无法撑开宽度,text-align:center 会失效 +.titleWrap { position: absolute; left: 120px; right: 120px; text-align: center; +} + +.title { font-size: 32px; font-weight: 600; color: $color-text; diff --git a/src/components/navbar/index.tsx b/src/components/navbar/index.tsx index 688fdc9..a8ab47e 100644 --- a/src/components/navbar/index.tsx +++ b/src/components/navbar/index.tsx @@ -42,7 +42,10 @@ export function Navbar({ )} - {title} + {/* title 用 View 包裹:text 标签 absolute 定位下宽度收缩导致居中失效 */} + + {title} + ) }