此背景速记是否会删除其他属性? [英] Does this shorthand for background removes the other attributes?
本文介绍了此背景速记是否会删除其他属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果我有
background:#A2A2A2 url('./images/img.png') repeat-x left bottom;
然后我使用:
background:#000000; /* not to confuse with 'background-color' */
background-image
,background-repeat
和background-position
是否丢失?
Do background-image
,background-repeat
and background-position
are lost?
推荐答案
background-image
,background-repeat
和 background-position
(除其他事项外)将在您隐式设置为默认值将它们留在速记属性中.多数情况下,这就是速记属性的工作方式.
background-image
, background-repeat
and background-position
(among other things) will be implicitly set to their default values when you leave them out in the shorthand property. It's just how a shorthand property works (for the most part).
计算出的背景样式最终看起来像这样:
The computed background styles end up looking something like this:
background-color: #000000; /* Your specified value */
background-image: none; /* Default value */
background-repeat: repeat; /* Default value */
background-position: 0% 0%; /* Default value */
是的,在第一个速记声明中设置的那些值将丢失.
So yes, those values you set in the first shorthand declaration will be lost.
这篇关于此背景速记是否会删除其他属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文