背景:和背景图像之间的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;
这篇关于背景:和背景图像之间的CSS区别:的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!