Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/39.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
背景图像的CSS定位_Css - Fatal编程技术网

背景图像的CSS定位

背景图像的CSS定位,css,Css,我需要bg.jpg,它是顶部带有黑色渐变的大背景,位于顶部,并且bg-bottom.jpg在底部重复。为什么这不起作用,有没有更简单的方法?除了创造一个长的形象 您在正文上的CSS应该是 html { background: #9c9c9c url(../images/bg-bottom.jpg) center top; } body { border-top:2px solid #fecd2a; background:#9c9c9c url(../images/bg.

我需要bg.jpg,它是顶部带有黑色渐变的大背景,位于顶部,并且bg-bottom.jpg在底部重复。为什么这不起作用,有没有更简单的方法?除了创造一个长的形象


您在
正文上的CSS应该是

html { 
    background: #9c9c9c url(../images/bg-bottom.jpg) center top;
}
body {
    border-top:2px solid #fecd2a;
    background:#9c9c9c url(../images/bg.jpg) repeat-x center bottom;
}

我认为在HTML标签中添加背景不会让你有任何进展。如果我是你,我只会制作一个超长、窄宽度的图像,它的长度不可能超过你的页面长度。如果不使用CSS3,您就不能有多个BG,我个人不推荐使用CSS3。

看起来您需要改变您的定位,并为
主体使用透明背景

background: url("../images/bg.jpg") repeat-x scroll #9C9C9C;

是的,会的。在
html
元素上设置的任何背景都应该通过
主体
元素的任何透明部分显示。是将颜色放在末尾更好,还是只是首选?背景:url(“../images/bg.jpg”)重复-x滚动#9c9c;据我所知,这没有任何区别。我相信这两种说法都是有效的,它们说明了一件不同的事情,结果是相同的-颜色首先设置背景颜色、背景图像、背景重复和背景附件-这意味着只有在图像不可用时才使用颜色。Color last设置背景图像、背景重复和背景附件,并另外声明,如果浏览器无法使用这些设置,则应使用另一个设置:仅包含背景颜色的设置。
html {  
    background: #9c9c9c url(../images/bg-bottom.jpg) center bottom 
} 

body { 
    border-top:2px solid #fecd2a; 
    background: transparent url(../images/bg.jpg) repeat-x center top; 
}