【问题标题】:How to put a style on a angular variable如何在角度变量上添加样式
【发布时间】:2019-11-20 22:34:30
【问题描述】:

您好,我想在 img 上添加样式 opacity:0.3

  <ion-content [style]="getBackgroundImg()">  

  getBackgroundImg() {
        const img = this.mediaDetails.image_path;
        const style = `background-image: url(${img}); `;
        return this.sanitizer.bypassSecurityTrustStyle(style);
 }

注意:我只想将不透明度放在 const img 上,而不是放在整个离子含量上。它不需要对象中的不透明度

【问题讨论】:

  • mediaDetails: any = {}; this.mediaDetails.image_path['opacity'] = "0.4";我得到'无法在字符串上创建属性不透明度'
  • 您想在 ion-content 中为图像添加不透明度?还是背景?
  • 在背景上,不是离子内容,因为我有内容按钮,数据等

标签: ionic-framework


【解决方案1】:

您可以在样式中添加 opacity 属性,例如

const style = `background-image: url(${img}); opacity:0.3 `;

【讨论】:

  • 我做到了。它不仅会改变图像,还会改变整个离子含量。
猜你喜欢
  • 2016-08-27
  • 1970-01-01
  • 1970-01-01
  • 2018-02-09
  • 1970-01-01
  • 2021-10-03
  • 2019-01-22
  • 2020-04-04
  • 1970-01-01
相关资源
最近更新 更多