Skip to main content

shorthand-property-no-redundant-values

禁止简写属性中存在冗余值。

¥Disallow redundant values within shorthand properties.

a { margin: 1px 1px 1px 1px; }
/** ↑ ↑ ↑

* These values */

你可以使用 速记属性 一次设置多个值。例如,你可以使用 margin 属性一次性设置 margin-topmargin-rightmargin-bottommargin-left 属性。

¥You can use shorthand properties to set multiple values at once. For example, you can use the margin property to set the margin-top, margin-right, margin-bottom, and margin-left properties at once.

对于一些速记属性,例如 那些与 盒子的边缘 相关的值,你可以安全地省略一些值。

¥For some shorthand properties, e.g. those related to the edges of a box, you can safely omitted some values.

此规则检查以下速记属性:

¥This rule checks the following shorthand properties:

  • margin, margin-block, margin-inline

  • padding, padding-block, padding-inline

  • border-color, border-style, border-width

  • border-radius

  • border-block-color, border-block-style, border-block-width

  • border-inline-color, border-inline-style, border-inline-width

  • gap, grid-gap

  • overflow,

  • overscroll-behavior,

  • scroll-margin, scroll-margin-block, scroll-margin-inline

  • scroll-padding, scroll-padding-block, scroll-padding-inline

  • inset, inset-block, inset-inline

fix 选项 可以自动修复此规则报告的所有问题。

¥The fix option can automatically fix all of the problems reported by this rule.

message 次要选项 可以接受该规则的参数。

¥The message secondary option can accept the arguments of this rule.

选项

¥Options

true

以下模式被视为问题:

¥The following patterns are considered problems:

a { margin: 1px 1px; }
a { margin: 1px 1px 1px 1px; }
a { padding: 1px 2px 1px; }
a { border-radius: 1px 2px 1px 2px; }
a { -webkit-border-radius: 1px 1px 1px 1px; }

以下模式不被视为问题:

¥The following patterns are not considered problems:

a { margin: 1px; }
a { margin: 1px 1px 1px 2px; }
a { padding: 1px 1em 1pt 1pc; }
a { border-radius: 10px / 5px; }