【问题标题】:Angular - how can i set an image from Api as background imageAngular - 我如何将 Api 中的图像设置为背景图像
【发布时间】:2021-02-01 09:22:05
【问题描述】:

我尝试将从我的 api 获取的图像设置为我的标题中的背景图像。但它不会按预期工作......

这是我的代码:

    <div class="container">
        <div class="header" [ngStyle]="{background: 'url('userProfile.headerImagePath')'}">
        ...

css

.header {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 500px;
    min-width: 100%;
    background-color: yellowgreen;
}

【问题讨论】:

标签: css angular


【解决方案1】:

请使用以下代码。

        <div class="header" [ngStyle]="{background: 'url('+userProfile.headerImagePath+')'}">
        ...

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-06-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-09-27
    • 2021-07-29
    相关资源
    最近更新 更多