简体   繁体   English

“0”vs“none”作为css属性值

[英]“0” vs “none” as css attribute value

I usually put 0 as value when i want to remove something in css. 当我想在css中删除某些东西时,我通常将0作为值。 For example: 例如:

border: 0;
background: 0;

Is there any difference between 0 and none ? 0none任何区别吗?

When used with composite styles like border and background , the values will correspond to different properties. borderbackground等复合样式一起使用时,值将对应于不同的属性。

border: 0 will set border-width: 0 while border: none will set border-style: none . border: 0将设置border-width: 0border: none将设置border-style: none

background: 0 will set background-position: 0 while background: none will set background-image: none . background: 0将设置background-position: 0background: none将设置background-image: none

So, there is a difference. 所以,有一个区别。 In the case of the border, the difference doesn't make any visual difference as both remove the border, but for the background it can make a difference if you also set any other background properties. 在边框的情况下,差异不会产生任何视觉差异,因为两者都删除边框,但对于背景,如果您还设置了任何其他背景属性,它可能会有所不同。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM