Skip to content

fix(home): 手机端首页只在词组之间换行 - #13

Merged
Kepler2024 merged 1 commit into
mainfrom
fix/home-mobile-wrap
Nov 26, 2026
Merged

Kepler2024 merged 1 commit into
mainfrom
fix/home-mobile-wrap

Conversation

@Kepler2024

Copy link
Copy Markdown
Owner

手机上首页标题和简介的句子比一行宽,浏览器会在任意位置折行:中文断在词中间(「编程|语言」「易错|陷阱」),英文把词组拆开("in a / new language"、"quick / onboarding")。text-wrap: balance 只会把各行拉得差不多长,不懂词组。

改动

  • 中英文首页的 h1 和简介按词组包进 <span class="phrase">。英文在逗号处分组,中文在顿号和句号处分组
  • global.css 新增 .phrase { display: inline-block; },窄屏只在词组之间换行
  • 桌面端排版不变:标题 2 行,简介每句 1 行

验证

  • 用 headless Chrome 在 320、360、375、390、402、430、700、769、900、1024、1280、1440、1920px 下逐行测量中英文首页的 h1 和简介:
    • 修复前:手机宽度共 20 处断在词组内部
    • 修复后:全部断在词组之间
    • 桌面宽度下:标题 2 行、简介 3 行
  • 桌面截图前后对比:只有亚像素抗锯齿差异,看不出区别
  • npm run build 和 npm run check 通过

🤖 Generated with Claude Code

On phones the hero sentences are wider than a line, so the browser broke
them wherever it could: inside Chinese words (编程|语言, 易错|陷阱) and
inside English phrases ("in a / new language", "quick / onboarding").
text-wrap: balance evens out line lengths but knows nothing about
phrases. Wrap each phrase of the homepage h1 and description in an
inline-block .phrase span so lines break only between phrases. Desktop
layout is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Kepler2024
Kepler2024 merged commit 5edde7f into main Nov 26, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant