【问题标题】:SweetAlert 2 v9 - how to write and insert a custom css?SweetAlert 2 v9 - 如何编写和插入自定义 css?
【发布时间】:2021-04-19 09:05:40
【问题描述】:

在哪里声明一个 CSS 类以及如何将它传递给 customClass 对象?

我正在尝试更改 SweetAlert 2 容器的默认布局,我想我必须使用 customClass 对象。但是,它只接收字符串。

我阅读了文档,但关于 customClass 的内容并不全面,感谢任何帮助。

【问题讨论】:

标签: css sweetalert2


【解决方案1】:

您必须指明要添加此自定义类的容器以及新类的名称,请参见下面的示例:

customClass: {
  container: 'container--modifier',
  popup: '...',
  header: '...',
  title: '...',
  closeButton: '...',
  icon: '...',
  image: '...',
  content: '...',
  htmlContainer: '...',
  input: '...',
  inputLabel: '...',
  validationMessage: '...',
  actions: '...',
  confirmButton: '...',
  denyButton: '...',
  cancelButton: '...',
  loader: '...',
  footer: '....'
}

这里是文档: https://sweetalert2.github.io/#customClass

添加此自定义类后,转到您的 css 文件并为元素设置所需的属性。

【讨论】:

  • 但是我在哪里声明 CSS 规则,例如容器自定义类?
  • 在您的 css 文件中。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-03-29
  • 1970-01-01
  • 2015-09-04
  • 2020-02-10
  • 1970-01-01
相关资源
最近更新 更多