'property: 0' 或 'property: 0px' 在 CSS 中? [英] 'property: 0' or 'property: 0px' in CSS?
问题描述
我已经看到这个符号被大量使用,我想知道这两个符号之间有什么显着区别吗?
I've seen this notation used a lot, and I was wondering, is there is any notable difference between these two notations?
element#id
{
property: 0;
}
和
element#id
{
property: 0px;
}
我一直使用 property: 0px;
,因为我觉得它看起来更简洁,但我不确定浏览器对 0px
的解释是否与 不同>0
.
I use property: 0px;
all the time, as I find it cleaner looking, but I'm not really sure if the browser interprets 0px
differently than 0
.
有谁知道哪个更好或更正确?
Does anyone know which one is better or correct?
推荐答案
虽然当值为 0
时单位是可选的,但我倾向于保留它,因为我可以用通过单击值并按向上/向下箭头键来打开 Chrome 的开发人员工具.没有单位,那真的不可能.
While the unit is optional when the value is 0
, I tend to leave it in, as I can then tweak the values with Chrome's Developer Tools by clicking on the value and pressing the up/down arrow keys. Without a unit, that isn't really possible.
此外,CSS 缩小器无论如何都会从 0
值中剥离单位,所以最终它并不重要.
Also, CSS minifiers strip the units off of 0
values anyways, so it won't really matter in the end.
这篇关于'property: 0' 或 'property: 0px' 在 CSS 中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!