问题描述
我看到这个符号使用了很多,我想知道,这两个符号之间有什么显着的区别吗?
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;
}
我使用属性: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? Thanks!
推荐答案
推荐答案
当值为
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 minifiers剥离
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'in CSS?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!