Html IE中的背景图像

Html IE中的背景图像,html,css,internet-explorer,Html,Css,Internet Explorer,出于一些奇怪的原因,IE中没有显示背景图像。我尝试过使用图像的完整路径,只使用背景而不是背景图像,使用png、gif、jpg,在图像路径周围使用引号和双引号。基本上尝试了IE中关于背景图片在网上的所有建议 html, body { margin: 0; padding: 0; width: 1008px; margin: 0 auto; font-family:"Trebuchet MS"; font-size:14px; line-height: 190%; text-align:left;

出于一些奇怪的原因,IE中没有显示背景图像。我尝试过使用图像的完整路径,只使用背景而不是背景图像,使用png、gif、jpg,在图像路径周围使用引号和双引号。基本上尝试了IE中关于背景图片在网上的所有建议

html, body {
margin: 0;
padding: 0;
width: 1008px;
margin: 0 auto; 
font-family:"Trebuchet MS";
font-size:14px;
line-height: 190%;
text-align:left;
text-decoration: italic;
background-image: url(../images/bgr_top.jpg), url(../images/bgr_bottom.jpg);
background-repeat: repeat-x, repeat-x;
background-position:center top, center bottom;
}
我唯一的怀疑是我使用了两张图片,一张在页面顶部,另一张在页面底部。 还可以阅读结束括号后的空格,但不确定是否相关,因为我使用的是背景重复:在另一行

欢迎提出任何其他建议:)

只能在支持css3的浏览器中工作&因此只有IE9+


支持所有浏览器的最佳方法是为每个背景使用单独的实体。

它们在不同的浏览器上工作吗?我会首先检查URL是否正确,图片是否存在,打开开发者工具,看看浏览器是否下载了它们,还需要只使用一个图片,看看你是否可以看到,而且IE 9不支持css 3,它可能会导致图片不显示。

只是想让你知道我是如何解决我的问题的。我已经添加了一个额外的div,它保存了整个网站,然后我将顶部图像添加到html中,将底部图像添加到css中的主体中

html {
    background: url("../images/bgr_top.jpg");background-repeat: repeat-x; background-position:center top;
    height: 100%;
}

body{
background: url("../images/bgr_bottom.jpg"); background-repeat: repeat-x; background-position:center bottom;

    margin: 0;
    padding: 0;
    margin: 0 auto; 
    font-family:"Trebuchet MS";
    font-size:14px;
    line-height: 190%;
    text-align:left;
     text-decoration: italic;

}

.main {
    margin: 0;
    padding: 0;
    width: 1008px;
    margin: 0 auto; 
    font-family:"Trebuchet MS";
    font-size:14px;
    line-height: 190%;
    text-align:left;
     text-decoration: italic;

}
结果 我现在在所有浏览器中都有两个背景,包括IE7、8等


希望这对其他人有所帮助。

如果需要,您可以使用root
标记上的psuedo元素来获得双重背景效果,这将在IE8+中工作,而无需添加额外的HTML。您是否可以添加一个小提琴或步骤来重现您的问题?愚蠢的问题,但您的页面是否具有渲染高度?如果由于某种原因,
的高度为零,它们将不会显示背景。这是在IE 10中工作的一种chrome。另外,如果我在IE中键入背景图像的路径,它会打开它。我读过一些关于JPG2000的问题,但这不是我的案例10不支持CSS3。我没有IE 9,但是有了8我可以打开图像。我使用的是css中的完整路径。你有没有看过使用?检查
html
body
标记的“跟踪样式”和“布局”,查看指定和渲染的高度。还可以检查“CSS”选项卡中那些元素上的任何划线。CSS没有任何划线。在跟踪栏中显示字体系列:“投石机MS”;字体大小:14px;线高:190%;对于布局,在布局选项卡上显示的带有偏移、边距、边框、填充和
宽度
高度
的图形不是
0
?PS,阅读下面的一些评论以获得答案,我认为它们的意思是你应该使用:
背景图像:url(../images/bgr_top.jpg)不带逗号,因为在较低的IE版本中不支持指定超过1个背景@ultraviol3tlux的建议是您获得IE8+支持的最佳选择。因此
width
height
0
应该是当时没有显示的原因。我注意到您根本没有指定高度(并且我不确定您是否在
正文
中有相对内容),也许将
高度:100%
添加到
html,正文
可以修复它?
html {
    background: url("../images/bgr_top.jpg");background-repeat: repeat-x; background-position:center top;
    height: 100%;
}

body{
background: url("../images/bgr_bottom.jpg"); background-repeat: repeat-x; background-position:center bottom;

    margin: 0;
    padding: 0;
    margin: 0 auto; 
    font-family:"Trebuchet MS";
    font-size:14px;
    line-height: 190%;
    text-align:left;
     text-decoration: italic;

}

.main {
    margin: 0;
    padding: 0;
    width: 1008px;
    margin: 0 auto; 
    font-family:"Trebuchet MS";
    font-size:14px;
    line-height: 190%;
    text-align:left;
     text-decoration: italic;

}