我遇到以下问题:我想使用 ngStyle 将背景图像插入我的网站。下面的代码工作正常:
<div [ngStyle]="{'background-image': 'url(' + myBackgroundUrl + ')', 'width': '224px', 'height': '248px'}"></div>
但是,如果我想向背景图像添加更多“属性”,该图像将不再可见:
<div [ngStyle]="{'background-image': 'url(' + myBackgroundUrl + ') no-repeat -228px 0', 'width': '224px', 'height': '248px'}"></div>
最佳答案
background-image 属性为元素设置一个或多个背景图像。
如果您想添加更多“属性”,请使用背景:
<div [ngStyle]="{
'background': 'url(' + myBackgroundUrl + ') no-repeat -228px 0',
'width': '224px',
'height': '248px'
}"></div>
关于angular - ngStyle 背景图像不可见,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59617869/