【问题标题】:Invalid background property无效的背景属性
【发布时间】:2018-05-07 12:07:53
【问题描述】:

enter image description here

我从外部 CSS 获取背景图像以显示。当我签入元素检查器时,它显示我使用了无效的属性。

body {
  font-family: 'Helvetica Neue', Arial, Helvetica, Verdana, sans-serif;
  margin: 0;
  padding: 0;
  background-image: url(../img/background.jpg);
  background-size: cover;
  overflow: hidden;
}

我在这里做错了什么?

【问题讨论】:

  • Inspector 会告诉你什么文件和文件中的哪一行。
  • 请明确您的问题标题和陈述
  • 您显示的代码中没有任何无效内容。请edit您的问题并提供minimal reproducible example
  • 用引号将网址括起来。 url("../img/background.jpg"); .
  • @priyadarshiswain 按照你说的尝试了还是不行。

标签: html css


【解决方案1】:

使用“背景”,而不是“背景图像”。即

background: url(../img/background.jpg);

【讨论】:

  • 非常感谢,终于知道了。
【解决方案2】:

你已经写了 background-image:url(..img/background.jpg) 这是正确的,可能是你插入了错误的路径,或者你可能在“background.jpg”文件中留了一个空格,像这样.. “backgroung .jpg”在创建图像名称时..检查一下..我在图像文件中留了很大的空间供您理解,可能只有一个空间

【讨论】:

  • 背景:url(../img/background.jpg);我是这样编码的。
  • 谢谢,我在 url 附近留了一个空格。
猜你喜欢
  • 2012-12-31
  • 2016-10-24
  • 2019-07-13
  • 1970-01-01
  • 2020-04-18
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多