css - Angular 动态背景图片

标签 css ipad angular styles

在 html 模板中,我有这种带有动态图像的样式:

<div style="background: url('/img/{{item.img}}'); width: 200px; height: 150px"></div>

适用于网络浏览器和安卓浏览器。但是,使用“style=”的动态背景图像不会在 iPad 上显示。

我总是可以使用 img 标签创建动态图像,但我正在寻找适用于 iPad 的样式/CSS 解决方案。

最佳答案

改用

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

另见 In RC.1 some styles can't be added using binding syntax

关于css - Angular 动态背景图片,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37575368/

相关文章:

ios - 旋转后保持 subview 相对位置

javascript - 使用 SASS 的 Angular 应用程序中的动态主题

angular 4/socket.io 访问全局变量和函数调用

Django 网站中的 Javascript 和 CSS 混淆/最小化?

c# - 从 HTML <figure> 和 <figcaption> 到 Microsoft Word

iphone - 如何在 iPhone/iPad 中创建通用应用程序?

iphone - 在 ipad 应用程序中绘制签名并将其转换为图像

javascript - d3.js 气泡图 : Make div scrollable

css - 样式化 md-tooltip(Angular Material 1.1.3)

typescript - ag Grid 使用 angular 和 typescript 搜索数据