background:和background-image之间的CSS差异: [英] css difference between background: and background-image:
问题描述
快速简单的问题 在以下外部CSS页面示例中;
quick simple question In the following example of an external CSS page;
body {
background-image: url(background.jpg);
}
header {
background: url(background.jpg);
}
我了解它们会影响不同的元素选择器,我的问题是使用背景与背景图像有什么区别?一个人可以访问另一个人的特定属性吗?谢谢,麻烦您了.
I understand they are effecting different element selectors, my question is what is the difference between using background vs background-image? Does one have access to specific attributes to the other? Please and thank you.
推荐答案
在背景属性中,您可以添加background-color
,repeat
,no-repeat
和其他图像属性,但是在background-image
属性中,您仅允许添加图像.
In a background property you can add background-color
, repeat
, no-repeat
and other image attributes, but in the background-image
property you are only allowed to add image.
background-image: url("img_tree.png");
background-repeat: no-repeat;
background-position: right top;
background-attachment: fixed;
在后台属性中,您可以全部一行完成
and in background property you can do in one line all these
background: #ccc url(paper.gif) no-repeat;
这篇关于background:和background-image之间的CSS差异:的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!