[英]background-image doesn't work with Chromes
我有一个背景图片,该背景图片在Firefox上显示得很好,但在Google Chrome浏览器上却根本没有显示。 我不明白...非常感谢。
编辑:我被告知,答案已经在其他地方,但没有。 我没有添加块,所以它不是同一个问题。 还是要谢谢你。
CSS:
#section2{
background: url(../images/references.png) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
position:relative;
}
HTML:
<div id="section2">
</div>
使用background-image:属性
#section2{
background-image: url(../images/references.png);
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
position:relative;
}
我不知道如何使用显示给我们的代码在firefox上看到图像。
Div大小无法调整为背景图片大小。 这意味着,如果您的div的高度和宽度为0,我们将无法看到背景图片。
如果将内容添加到div或CSS中的宽度和高度,您将看到图像出现。
#section2 { background: url('https://images.unsplash.com/photo-1518791841217-8f162f1e1131?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&w=1000&q=80') no-repeat center center fixed; -webkit-background-size: cover; -moz-background-size: cover; -o-background-size: cover; background-size: cover; position: relative; height: 500px; width: 500px; }
<div id="section2"></div>
div中没有高度/内容,因此您什么也看不到。 反正代码很好
#section 2 {
height: 200px;
width: 200px;
}
将此添加到ur css
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.