什么呢背景:透明的网址();做? [英] what does background: transparent url(); do?

查看:148
本文介绍了什么呢背景:透明的网址();做?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看到一个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:


  1. 不使用简写,而是直接使用背景颜色属性;

  2. 用它来替代直接申请该元素的另一个选择。

一个例子是

body.foo { background-color: blue; }
body.foo.bar { background-color: transparent; }

这篇关于什么呢背景:透明的网址();做?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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