【问题标题】:Ionic/Angular CSS Problems with image图像的 Ionic/Angular CSS 问题
【发布时间】:2020-07-13 14:46:36
【问题描述】:

我在 css 文件中设置背景图像,过去 13 年来我一直在这样做,但由于某种原因,ionic/angular 搞砸了。 在我的 css 文件中,我有这个:

.bg {
    background-image: url('../../../assets/headers/address.png');
}

但它不渲染图像,当我检查元素时它写道:

背景图片:url(address.png)

【问题讨论】:

  • 你还需要添加目录结构,以便其他人可以看到这个css文件与assets文件夹的关系。
  • 嘿@Prince scr > assets > headers > 'images here' 至于结构的其余部分:src > app > subscription > uaddress > 'ts, scss, html here'。

标签: css angular ionic-framework sass ionic5


【解决方案1】:

你可以试试这个css,

.image{
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    background: url(D:\qwe\ert\apn\dashboard\src\assets\icon\favicons\android-chrome-384x384.png) no-repeat center top;//address image
}

【讨论】:

  • 应用程序编译后将无法工作,因为编译器上不存在绝对路径。它需要来自本地主机或类似的东西。
【解决方案2】:

它通过删除所有../ 并留下/assets/ 来工作

【讨论】:

    猜你喜欢
    • 2021-09-25
    • 1970-01-01
    • 2018-01-11
    • 2020-11-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多