Is {background:0;} valid CSS?

随声附和 提交于 2019-12-23 10:24:46

问题


I understand that background is the shorthand property - what will the value 0 do to all of the properties and is it valid CSS?

selector {background:0;}

回答1:


background:0 is valid css and gets compiled into:

background-image: initial;
background-position-x: 0px;
background-position-y: 50%;
background-size: initial;
background-repeat-x: initial;
background-repeat-y: initial;
background-attachment: initial;
background-origin: initial;
background-clip: initial;
background-color: initial;



回答2:


Yes, the zero will be interpreted as the horizontal background position. The other background properties are set to the default values, so you end up with the same as:

background-image: none;
background-repeat: repeat;
background-attachment: scroll;
background-position: 0 center;
background-color: transparent;


来源:https://stackoverflow.com/questions/24306770/is-background0-valid-css

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!