logical-properties
它能做什么
这项技能把使用固定方向(例如左和右)的 CSS 更新为随阅读方向变化的逻辑属性。适用于希望网站支持多种语言的开发者。
适用场景
- ✓当你请智能体为从右到左书写的语言准备样式表的时候。
- ✓当你要添加阿拉伯语、希伯来语或波斯语支持,而这些语言的布局显示有误的时候。
- ✓当你审查 CSS,并想把 margin-left 等属性替换为会自动适应的版本的时候。
技能链接
https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/logical-properties/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请帮我更新 CSS,让阿拉伯语和希伯来语读者的布局显示正常。”
每周 5 个新技能,1 分钟读完。
工作原理
智能体会找到使用固定方向的间距和定位规则,并把它们替换为行内和块级的对应属性。当文字方向改变时,布局会自动翻转。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Use CSS logical properties for i18n and RTL support
Physical CSS properties (margin-left, padding-right) are hardcoded to screen directions. In right-to-left languages (Arabic, Hebrew, Persian), what should be margin-left becomes margin-right. Without logical properties, supporting RTL requires maintaining duplicate stylesheets or complex overrides with [dir=rtl] selectors. Logical properties handle this automatically.
Quick Reference
- Logical properties adapt to writing direction — margin-inline-start is left in LTR, right in RTL
- Replace left/right margin and padding with inline-start/inline-end equivalents
- Replace top/bottom with block-start/block-end equivalents
- Logical properties also work correctly for vertical writing modes
Check
Find all uses of margin-left, margin-right, padding-left, padding-right, border-left, border-right, left, right (as positioning) that should be converted to logical equivalents.
Fix
Convert physical direction properties to their CSS logical property equivalents for RTL and internationalization support.
Explain
Explain CSS logical properties, the difference between physical and logical directions, and how they enable RTL language support.
Code Review
Review stylesheets, component styles, and responsive states related to Use CSS logical properties for i18n and RTL support. Flag exact selectors, declarations, or breakpoints that violate the rule in the rendered UI.
For full implementation details, code examples, and framework-specific guidance,
see references/rule.md.
Rule page: https://frontendchecklist.io/rules/css/logical-properties
常见问题
我还需要为从右到左的语言单独编写样式吗?
通常不需要。逻辑属性会自动处理方向,因此通常可以避免重复的样式表或额外覆盖。
逻辑属性对竖排文字有帮助吗?
有帮助。这项技能指出,它们在竖排书写模式下也能正确工作。
修改后应该检查布局吗?
应该。这项技能建议在不同屏幕尺寸和交互状态下检查渲染后的布局。
详情
作者的原始描述
Use when reviewing stylesheets, component styles, and responsive behavior related to Use CSS logical properties for i18n and RTL support. Check the rendered layout across breakpoints and interaction states before proposing a fix.
热度
- GitHub 星标
- 75k
- 排名
- #2931
- 许可证
- MIT
- 更新时间
- 2026/10/31
评论
- …
同一仓库的更多技能
frontendchecklist
75k使用命令行工具,依据 380 多条关于无障碍、速度、SEO 和安全的规则,检查前端代码和线上页面。
frontend-checklist-global
75k依据全部 386 条 Front-End Checklist 规则审查前端项目,并为发现的每个问题给出具体修复方法。
404-page
75k检查你的页面缺失提示是否提供有用的链接,并返回真正的 404 状态,帮助迷路的访客找到方向。
about-page
75k审查你的网站是否有清晰的关于页面,说明由谁运营,以建立访客和搜索引擎的信任。