是什么背景和背景色之间的差异 [英] What is the difference between background and background-color
问题描述
有什么用指定的背景颜色背景
和背景颜色
?
片段#1
{身体背景色:蓝色; }
片段#2
{体背景:蓝色; }
premising那些是两个不同的属性,请在具体的例子有在结果没有任何区别,因为背景
实际上是一条捷径。
背景颜色结果
背景图片结果
背景位置结果
背景重复结果
背景附件结果
背景夹结果
背景出身结果
背景大小
块引用>因此,除了在
背景颜色
,使用背景
快捷方式,你还可以添加一个或多个值不重复任何其他背景 - *
属性不止一次选择哪一个基本上是你的,但它也可能取决于你的风格声明(如具体情况,如果你需要覆盖不仅仅是
背景颜色
继承等相关背景时 - 从父元素*
属性,或者如果您需要删除除背景色中的所有值
)。What's the difference between specifying a background color using
background
andbackground-color
?Snippet #1
body { background-color: blue; }
Snippet #2
body { background: blue; }
解决方案Premising that those are two distinct properties, in your specific example there's no difference in the result, since
background
actually is a shortcut forbackground-color
background-image
background-position
background-repeat
background-attachment
background-clip
background-origin
background-sizeThus, besides the
background-color
, using thebackground
shortcut you could also add one or more values without repeating any otherbackground-*
property more than once.Which one to choose is essentially up to you, but it could also depend on specific conditions of your style declarations (e.g if you need to override just the
background-color
when inheriting other relatedbackground-*
properties from a parent element, or if you need to remove all the values except thebackground-color
).这篇关于是什么背景和背景色之间的差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!