【问题标题】:SweetAlert2 - How to change title and text color?SweetAlert2 - 如何更改标题和文本颜色?
【发布时间】:2021-11-02 02:23:00
【问题描述】:

我想更改 SweetAlert2 中的标题和文本颜色。

我的提醒:

Swal.fire({
  icon: 'warning',
  title: 'Attention...',
  text: 'Change color of this text',
  background: '#1e2122',
  confirmButtonColor: '#ff6600',
  confirmButtonText: 'OK',
  iconColor: '#ff6600',
})

我见过这个topic,但对我不起作用。

需要使用customClass吗?

你能帮帮我吗? :)

谢谢。

【问题讨论】:

    标签: javascript sweetalert sweetalert2


    【解决方案1】:

    尝试在 SWAL 配置中使用 customClass 为标题或容器提供自定义类名称,并在该类中提供文本颜色。

    SWAL customClass Configuration

    调用 SWAL 时的配置应包含 customClass 键,其值类似于

    customClass: {
        title: 'custom-title-class',
      }
    

    在您的根 CSS 文件中

    .custom-title-class {
      color: green;
    }
    

    类似地,其他样式也可以使用它们各自的条目来覆盖。

    【讨论】:

    • 谢谢丹!但我不太了解如何使用自定义 CSS 类?我把 CSS 代码直接放在 '...' 里面? customClass: { title: 'put css here ?', }谢谢
    • 非常感谢丹!你的解释一切正常:)
    • 乐于帮助@Maxime!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-06-17
    • 1970-01-01
    • 2017-07-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多