什么呢背景:透明的网址();做? [英] what does background: transparent url(); do?
问题描述
我看到一个css code其中有人喜欢
I saw a css code where it was like
body { background: transparent url ('background.jpg') repeat scroll;}
什么是透明的价值呢?我试图google'ing关于这一点,但没有帮助。会不会只是background.jpg覆盖它?
What does the transparent value do? I tried google'ing about this, but no help. Wouldn't background.jpg just override it?
感谢您。
推荐答案
透明
是颜色。一个元件可以同时具有背景图像和一个背景颜色。
transparent
is the color. An element can have both a background image and a background color.
上面相当于:
body {
background-color: transparent;
background-image: url('background.jpg');
background-repeat: repeat;
background-attachment: scroll;
}
颜色是一般的重要,如果如背景图像加载失败,或图像中包含透明区域,或者图像不会重复以填充整个区域(这是无可否认不是在你的例子一样)。
The color is important in general if e.g. the background image fails to load, or the image contains transparent regions, or the image does not repeat to fill the entire area (which is admittedly not the case in your example).
不过,由于透明
使用背景
速记时是初始值,这是从来没有必要,因为速记自动将所有未指定属性的初始值。
However, since transparent
is the "initial value", it is never necessary when using the background
shorthand, since the shorthand automatically sets all unspecified properties to their initial value.
因此,其中透明
有意义的,因为背景颜色只用例涉及:
Thus, the only use case where transparent
makes sense as a background color involves:
- 不使用简写,而是直接使用
背景颜色
属性; - 用它来替代直接申请该元素的另一个选择。
一个例子是
body.foo { background-color: blue; }
body.foo.bar { background-color: transparent; }
这篇关于什么呢背景:透明的网址();做?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!