使用background
和background-color
指定背景色有什么不同?
Snippet #1个
body { background-color: blue; }
Snippet #2
body { background: blue; }
使用background
和background-color
指定背景色有什么不同?
Snippet #1个
body { background-color: blue; }
Snippet #2
body { background: blue; }
假设这是两个不同的属性,在你的具体例子中,结果没有区别,因为background
实际上是
background-color background-image background-position background-repeat background-attachment background-clip background-origin background-size
因此,除了background-color
之外,使用background
速记还可以添加一个或多个值,而无需多次重复任何其他background-*
属性.
Select 哪一个基本上取决于您,但也可能取决于样式声明的特定条件(例如,从父元素继承其他相关background-*
属性时是否只需要覆盖background-color
,或者是否需要删除除background-color
之外的所有值).