是什么背景和背景色之间的差异 [英] What is the difference between background and background-color

查看:110
本文介绍了是什么背景和背景色之间的差异的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么用指定的背景颜色背景背景颜色

之间的区别

片段#1

  {身体背景色:蓝色; }

片段#2

  {体背景:蓝色; }


解决方案

premising那些是两个不同的属性,请在具体的例子有在结果没有任何区别,因为背景实际上是一条捷径。


  

背景颜色结果
  背景图片结果
  背景位置结果
  背景重复结果
  背景附件结果
  背景夹结果
  背景出身结果
  背景大小


因此​​,除了在背景颜色,使用背景快捷方式,你还可以添加一个或多个值不重复任何其他背景 - * 属性不止一次

选择哪一个基本上是你的,但它也可能取决于你的风格声明(如具体情况,如果你需要覆盖不仅仅是背景颜色继承等相关背景时 - 从父元素* 属性,或者如果您需要删除除背景色中的所有值)。

What's the difference between specifying a background color using background and background-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 for

background-color
background-image
background-position
background-repeat
background-attachment
background-clip
background-origin
background-size

Thus, besides the background-color, using the background shortcut you could also add one or more values without repeating any other background-* 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 related background-* properties from a parent element, or if you need to remove all the values except the background-color).

这篇关于是什么背景和背景色之间的差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆