有角度的动态背景图片 [英] Angular dynamic background images

查看:28
本文介绍了有角度的动态背景图片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 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>

适用于网络浏览器和安卓浏览器.然而,使用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>

另见 在RC.1 某些样式无法使用绑定语法添加

这篇关于有角度的动态背景图片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆