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} + ) }