角度动态背景图片 [英] Angular dynamic background images
本文介绍了角度动态背景图片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在html模板中,我具有带有动态图像的这种样式:
In the html template I have this style with a dynamic image:
<div style="background: url('/img/{{item.img}}'); width: 200px; height: 150px"></div>
可在网络浏览器和android浏览器中使用.但是,使用"style ="动态显示的背景图像不会在iPad上显示.
Which works in web browsers and android browser. However background images that are dynamic using "style=" are not showing on iPad.
我总是可以使用img标签创建动态图像,但是我正在寻找iPad的样式/css解决方案.
I could always create dynamic images using the img tag but I'm looking for a style/css solution for iPad.
推荐答案
改为使用
<div [ngStyle]="{background: 'url(/img/' + item.img + ')', width: '200px', height: '150px'"></div>
或
<div [style.background]="'url(/img/' + item.img + ')'"
[style.width.px]="200" [style.height.px]="150p"></div>
这篇关于角度动态背景图片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文