简体   繁体   English

Firefox和IE中不显示背景图片

[英]Background image doesn't show in firefox and IE

I'm new to bootstrap and overall web design. 我是引导程序和整体Web设计的新手。 Using the original bootstrap.css and the bootstrap's default html file, I added this as my custom css : 使用原始的bootstrap.css和bootstrap的默认html文件,将其添加为自定义css:

 body {
    margin: 0;
    background: url("some image url");
    background-position: center top;
    background-size: 1440px 800px;
    background-repeat:no-repeat;
    display: compact;
}

and it works fine on chrome but it doesn't show up on IE or firefox. 并且它在chrome上可以正常工作,但在IE或Firefox中却无法显示。 Using firebug I inspected the css and got this : 使用萤火虫,我检查了CSS并得到了:

body {
   background: url("some image url") repeat scroll center top / 1440px 800px rgba(0, 0, 0, 0);
   margin: 0;
  }

But I still can't figure out where the problem is. 但是我仍然不知道问题出在哪里。 Is there any other way to write the simple CSS snippet so IE and firefox can work with it? 还有其他方法可以编写简单的CSS代码段,以便IE和firefox可以使用它吗?

edit : I fixed the semi colon issue but still not showing up. 编辑:我解决了分号问题,但仍然没有出现。 Firebug showing : 萤火虫显示:

body {
margin: 0;
background: url("some image url");
background-position: center top;
/* background-size: cover; */
background-size: 1440px 800px;
background-repeat:no-repeat; 
display: compact;
  }

EDIT : I had to put the direct path to the image vs using a url. 编辑:我不得不把直接路径到图像与使用URL。 Thank you all for your suggestions and help! 谢谢大家的建议和帮助!

http://www.w3schools.com/css/css_background.asp http://www.w3schools.com/css/css_background.asp

You need to change 你需要改变

background: url("some image url");

into

background-image: url("some image url");

您好@tyrell_c我认为问题可能是Firefox不支持“ display:compact”,也请尝试省略图片网址中的引号

好吧,所有其他答案都很好,我总是使用它们,但是如果它们不起作用,您可能会做一个简单的技巧,例如在刚开始的身体上添加img,并将其高度和宽度设置为100%,以使照片成为根据屏幕尺寸做出响应。这将拉伸照片,并且对用户而言将像背景照片一样,因为它看起来相同

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM