跳到正文
Skillpedia
网站与界面(前端)75k · #2931

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。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/logical-properties/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 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.

repo: thedaviddias/Front-End-Checklist

热度

GitHub 星标
75k
排名
#2931
许可证
MIT
更新时间
2026/10/31

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能