ionic-framework - 如何将 css 应用到 ionic 警报内的文本?

标签 ionic-framework sass alert

我有一个警报,其中有一些文本和一个 ionic 图标,我想更改其颜色并调整其大小和位置(中心),我创建了一个 css 类尝试应用它,但它不起作用,即使我想HTML 似乎可以工作,我使用了 <b>标签就好了。
我的代码:

async presentAlertError(data) {
    const alert = await this.alertController.create({
      header: 'Confirmation',
      message: '<ion-icon name="close" class="custom-icon-notfound" > </ion-icon>'  + "Registration " + data.statusText,
      buttons: [
        {
          text: 'Cancel',
          role: 'cancel',
          cssClass: 'secondary',
          handler: (aux) => {
            console.log('Confirm Cancel: aux');
          }
        }, {
          text: 'Scan Next',
          handler: () => {
            this.scanCode();
            console.log('Confirm ');
          }
        }
      ]
    });
    await alert.present()

我应该以不同的方式做到这一点吗?

最佳答案

ionic 警报不会显示在主页或(无论您在哪个页面/组件上发出警报)影子 DOM 中,因此如果您将其添加到那里,样式不会影响它,您必须将样式添加到位于与警报的范围相同。我将该类添加到variables.scss,因为它具有最高的范围:

变量.scss-

   .secondary {
            color: #A0A !important;
            font-size: 2em !important;
        }

   .custom-icon-notfound {color: red}

enter image description here

还需要添加 !important,这样它就会忽略之前的样式。

关于ionic-framework - 如何将 css 应用到 ionic 警报内的文本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55523510/

相关文章:

JavaFX 警报不会在新窗口中打开,而是在新选项卡中打开

html - 如何在 ionic v4 的 item-native div 中编辑 "item-inner"类?

javascript - Angular.js : Storing variable from http.获取在不同$scope函数中全局使用的请求

ionic-framework - 使用 Socket.IO 创建 VOIP 聊天应用程序

import - 是否可以使用 @import 在 sass 中导入整个目录?

javascript - 延迟 sweetalert2 中按钮的出现

java - 日志: How to get a email whenever there is a Exception inside Log

javascript - 根据条件动态地将脚本添加到我的应用程序

reactjs - useRef.current.contains 不是函数

CSS --Sass 颜色变量