css - 在 CSS 透视图上使用单位

标签 css perspective css-transforms

只是一个简短的问题,以澄清我对 CSS perspective 上的单位的一些困惑。

在 CSS Transforms 规范中,它用 px 引用它,例如perspective: 1000px; 但我已经使用过并且在许多其他地方其他人在没有 px 的情况下使用过它,例如perspective: 1000; 例如 W3Schools。

哪种方式更受欢迎?重要吗?

只是想解决这个问题,谢谢。

最佳答案

仅仅因为它被(某些)浏览器接受并不意味着它是正确的。 指定测量单位是 required by the CSS spec ,除非值为零。

规范说:

Lengths refer to distance measurements and are denoted by <length> in the property definitions. A length is a dimension. A zero length may be represented instead as the <number> ‘0’. (In other words, for zero lengths the unit identifier is optional.)

A dimension is a number immediately followed by a unit identifier.

(强调我的)

参见 Distance UnitsOther Units例如。

另请参阅 length 的 MDN 讨论

关于css - 在 CSS 透视图上使用单位,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11997177/

相关文章:

jquery - 打开时突出显示带有类的选择/下拉列表,或者具有除初始默认选择之外的选项

css - 输入[类型= radio ] :before radio sticking out

javascript - 当窗口从顶部滚动一定距离时 div 淡入

css - Firefox 中 CSS 形状的抗锯齿

jquery - Bootstrap Carousel 多列一次滑动 1

python-3.x - 如何使用opencv python在各种彩色背景中找到文档边缘? 【各种背景下的文档扫描】

3d - 消失点如何帮助恢复正确的相机视角?

javascript - CSS3 rotate3d pr rotateX 获取元素的实际高度

css - 将 1% 宽度的 div 放大 100 倍并不能覆盖父级的整个宽度

google-chrome - Chrome-webkit-转换 : scale($val) does not anti-alias scaled image