MDN声明您可以使用 1-4 之间的数字作为长度属性,但它没有任何效果。
有什么原因吗?
P {
font-size: 0.85em;
màu nền: đỏ;
border-radius: 4;
}
Alice was beginning to get very tired of sitting by her sister on the bank, and of having nothing to do: once or twice she had peeped into the book her sister was reading, but it had no pictures or conversations in it, 'and what is the use of a book,'
thought Alice 'without pictures or conversations?'
结果:https://jsfiddle.net/6L31f9d6/
Note: The points indicated by Thieu Nguyen are valid. I am adding a separate answer because I think your problem is due to the interpretation (wrong) of the formal syntax and because I'm not comfortable forcing my content into another answer.
MDN page for border-radius
无处说明我们可以使用 1-4 之间的数字作为长度值。事实上,CSS 中的所有长度值Tất cả phải后跟一个单位,唯一的异常(exception)是 0。
以下是 CSS Spec for Length Units 的摘录: (重点是我的)
The format of a length value is an optional sign character ('+' or '-', with '+' being the default) immediately followed by a number (with or without a decimal point) immediately followed by a unit identifier (a two-letter abbreviation). After a '0' number, the unit identifier is optional.
dựa trên your comment , 我觉得你混淆了 {1,4}
在正式语法中为无单位值。
[ | ]{1,4} [ / [ | ]{1,4} ]?
但它们不是无单位值。它就像在 RegEx 中,其中 [a]{x,y}
表示 a 的最少 x 次出现 Và 最多 y 次出现。因此,以下是应如何解释正式语法:
-
[ | ]
- 表示长度或百分比可以是值。
-
{1,4}
- 表示前一个实体必须至少出现一次,最多出现四次。也就是说,该值应至少为一个长度或百分比,最大为四个长度或百分比。
-
[ / [ | ]{1,4} ]?
- 与上面类似,但末尾的问号表示该位是可选。即 /
后面的长度或百分比值是可选的。如果提供,它们将用作垂直边界半径,如果不提供,它们将与水平半径相同。
Tôi là một lập trình viên xuất sắc, rất giỏi!