【问题标题】:Why does the background image css not working?为什么背景图像 css 不起作用?
【发布时间】:2021-06-01 23:30:32
【问题描述】:

我不明白为什么图像鸡蛋没有显示。

这是用于:

的代码
.header {
    background: 
    linear-gradient(180deg, rgba(0, 0, 0, 0.92), rgba(54, 54, 54, 0.5) 39.24%, rgba(28, 28, 28, 0.4)), 
    url("/img/eggs.jpg") center center / cover no-repeat;
    color: #FFF;
}

网站:https://le-fiasco.netlify.app/ Github:https://github.com/fawraw/lefiasco

谢谢!

【问题讨论】:

  • 您的网站linear-gradient(180deg, rgba(0, 0, 0, 0.92), rgba(54, 54, 54, 0.5) 39.24%, rgba(28, 28, 28, 0.4)), + url(/img/eggs.jpg) center center / cover no-repeat 上有错字。看到多余的“+”了吗?只需将其删除。
  • 谢谢 Amaury,你是对的!它现在正在工作;)

标签: html css image url


【解决方案1】:

我认为图片url的相对路径有问题,

我使用了一些来自网上的图片,它工作正常,具有确切的属性,

#test{

width : 100px;
height : 40px;
background: linear-gradient(
180deg
, rgba(0, 0, 0, 0.92), rgba(54, 54, 54, 0.5) 39.24%, rgba(28, 28, 28, 0.4)), url(https://1onjea25cyhx3uvxgs4vu325-wpengine.netdna-ssl.com/wp-content/uploads/2020/11/Hello-World_Blog-1536x864.jpeg) center center / cover no-repeat;
    color: #FFF;

}
<div id = "test"></div>

【讨论】:

  • 我已经为这个 img 测试了其他路径: url("/img/eggs.jpg") url("img/eggs.jpg") url("../img/eggs.jpg" ) 还是不行。
猜你喜欢
  • 2016-09-27
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-04-22
  • 2014-08-31
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多