【问题标题】:CSS background image not displaying as expectedCSS 背景图像未按预期显示
【发布时间】:2023-01-29 22:55:16
【问题描述】:

我想在背景中,在一个大 div 的两端放置一个图像。

CSS代码:

}
.headall {
    background-color: #44546a;
    /*width: 100%;*/
    /*top: 0 !important;*/
}
.headl {
    width: 12%;
    float: left;
    /*display: table-cell;*/
    justify-content: right;
    transform: scaleX(-1);
    background-image: url(./images/leaves.png);
    background-repeat: no-repeat;
    background-size: 130px;
    
}

.headctr {
    width: 76%;
    display: inline-block;
    justify-content: center;
}

.headr {
    width: 12%;
    float: right;
    display: table-cell;
    justify-content: right;
    background-image: url(./images/leaves.png);
    background-repeat: no-repeat;
    background-size: 130px;
}

但是,图像不会显示。

将图像放在主文件中,工作,但它把它放在前台....

【问题讨论】:

  • 如果您说的是 in main fil working,我想它在主 HTML 文件中。所以也许你必须检查图像上的路径。在这里你有 1 个文件夹,然后是文件夹图像
  • 请发送您的 HTML
  • 每小时“为什么我的图像不显示?”它总是返回答案“你的路径名是错误的”

标签: css background-image


【解决方案1】:

您需要添加引号。如果您的图像文件与您的 css 不在同一文件夹中,则需要两个点。

background-image: url("../images/leaves.png");

【讨论】:

  • 谢谢你。我现在觉得很愚蠢,因为那是我没有尝试过的事情!
  • @DoodlesUK 不要觉得自己很傻,我们中最好的人都会遇到这种情况!
猜你喜欢
  • 2019-10-24
  • 1970-01-01
  • 2015-07-10
  • 2012-06-12
  • 1970-01-01
  • 2012-02-08
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多