简体   繁体   English

没有显示背景图片。 为什么?

[英]Background image isn't showing up. Why?

I'm really stuck. 我真的被卡住了。 I'm a beginner in CSS and i try to work with a background image. 我是CSS的初学者,我尝试使用背景图片。

When i don't use the parameter no-repeat everything works well but with no-repeat the image don't show up. 当我不使用参数no-repeat一切正常,但使用no-repeat ,图像不会显示。 Is this a size problem? 这是尺寸问题吗?

I've tried to work with <style></style> but this also doesn't work. 我尝试使用<style></style>但这也不起作用。

Any help much appreciated! 任何帮助,不胜感激!

  #bg--service { background-image: url('http://www.sternwarte-radebeul.de/Images_vstw/fotos/sterngucker.jpg') no-repeat; } 
 <div class="row articles" id="bg--service"> <div class="col-sm-6"> <div class="col-xs-12 article"> <h1>Treuhand und Finanzen</h1> <p>Sie wollen sich auf Ihren Fachbereich konzentrieren, brauchen Unterstützung in Ihren Finanzen, eine Fiskal- oder Steuervertretung oder wollen Ihre Freizeit nicht mit buchhalterischen Fragen belasten?<a href=“#”>Mehr>></a> </p> </div> 

You're using the background shorthand notation in the background-image property, which won't work. 您在background-image属性中使用了background速记符号,该符号不起作用。

Change 更改

background-image: url(../img/sternengucker.jpg) no-repeat;

to

background: url(../img/sternengucker.jpg) no-repeat;

Or use two separate rules like: 或使用两个独立的规则,例如:

background-image: url(../img/sternengucker.jpg);
background-repeat: no-repeat;

background-image only accept the image property. background-image仅接受image属性。

If you use the following it will work: 如果使用以下命令,它将起作用:

background-image: url('../img/sternengucker.jpg');
background-repeat: no-repeat;

You can read more about the background image property here: https://developer.mozilla.org/en-US/docs/Web/CSS/background-image 您可以在此处了解有关背景图片属性的更多信息: https : //developer.mozilla.org/en-US/docs/Web/CSS/background-image

You can also use the background shorthand: 您还可以使用背景速记:

background: url('../img/sternengucker.jpg') no-repeat top left;

This link shows more information about the background shorthand: 此链接显示有关背景速记的更多信息:

https://developer.mozilla.org/en-US/docs/Web/CSS/background https://developer.mozilla.org/zh-CN/docs/Web/CSS/background

Use: 采用:

#bg--service {
    background: url(../img/sternengucker.jpg) no-repeat;
}

If you want to use background-image , then use this: 如果要使用background-image ,请使用以下命令:

#bg--service {
    background-image: url(../img/sternengucker.jpg);
    background-repeat: no-repeat;
}

And then read this: 然后阅读:

documentation background-image 文档背景图片

documentation background-repeat 文档背景重复

Or whole documentation about background and its properties here . 有关背景和它的属性或整个文档在这里

The background image and background-repeat are sub-properties of the background property so to fix it the background-image should be replaced with background . background imagebackground-repeat是背景属性的子属性,因此要对其进行修复,应将background-image替换为background

  #bg--service { background: url('http://www.sternwarte-radebeul.de/Images_vstw/fotos/sterngucker.jpg') no-repeat; } 
 <div class="row articles" id="bg--service"> <div class="col-sm-6"> <div class="col-xs-12 article"> <h1>Treuhand und Finanzen</h1> <p>Sie wollen sich auf Ihren Fachbereich konzentrieren, brauchen Unterstützung in Ihren Finanzen, eine Fiskal- oder Steuervertretung oder wollen Ihre Freizeit nicht mit buchhalterischen Fragen belasten?<a href=“#”>Mehr>></a> </p> </div> 

or you can separate the line in two properties 或者您可以将行分为两个属性

  #bg--service { background-image: url('http://www.sternwarte-radebeul.de/Images_vstw/fotos/sterngucker.jpg'); background-repeat: no-repeat; } 
 <div class="row articles" id="bg--service"> <div class="col-sm-6"> <div class="col-xs-12 article"> <h1>Treuhand und Finanzen</h1> <p>Sie wollen sich auf Ihren Fachbereich konzentrieren, brauchen Unterstützung in Ihren Finanzen, eine Fiskal- oder Steuervertretung oder wollen Ihre Freizeit nicht mit buchhalterischen Fragen belasten?<a href=“#”>Mehr>></a> </p> </div> 

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

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