'use client'; import { Layout, Section, Article, Headline, Subhead, BodyText, Rule, } from 'newspaperui'; import { CodeBlock } from '@/components/CodeBlock'; export default function ResponsivePage() { return (
响应式设计 NewspaperUI 的响应式策略完全基于 CSS media query + container query, 不依赖 JavaScript 运行时计算。 断点说明

三个核心断点覆盖移动、平板、桌面:

断点 宽度 栏数建议 说明
Mobile < 768px 1 栏(全宽) 单栏堆叠,BodyText columns=1
Tablet 768px - 1024px 12 列 两栏布局,BodyText columns=2
Desktop > 1024px 24 列 完整多栏布局
实施手法

NewspaperUI 不再使用 JavaScript responsive 函数。所有响应式行为通过 CSS media query 和 container query 实现,零运行时开销。

Section 的 gridTemplateColumns 是 inline style,因此需要在 消费侧用 CSS 覆盖。推荐做法:

或者使用 container query 让 Section 根据自身宽度自适应:

视口效果预览

下面三个区块模拟桌面、平板、移动端的视觉效果。实际项目中建议使用浏览器 DevTools 的 responsive mode 进行测试。

Desktop (1024px+) — 24 列完整布局
Briefing

Short news items.

Lead Story

Main article content with full detail.

Markets

FTSE, gilts, sterling.

Tablet (768-1024px) — 12 列简化
Lead Story

Main article.

Secondary

Supporting content.

Mobile (<768px) — 单栏堆叠
Lead Story

Full-width single column.

Secondary

Stacked below.

); }