javascript - SweetAlert - 更改模式颜色

标签 javascript css sweetalert2

默认颜色为白色。 是否可以更改 sweetalert2 的模态背景颜色?

我尝试用 CSS 来改变它,正如我在另一个问题 here 上所遵循的那样和 here ,像这样:

.sweet-alert 
{
   background-color: #2f2f2f96;
}

但我什么也没得到,

我使用sweetalert问题功能

Swal.mixin({
  input: 'text',
  confirmButtonText: 'Next →',
  showCancelButton: true,
  progressSteps: ['1', '2', '3']
}).queue([
  {
    title: 'Question 1',
    text: 'Chaining swal2 modals is easy'
  },
  'Question 2',
  'Question 3'
]).then((result) => {
  if (result.value) {
    Swal.fire({
     title: 'All done!',
     html:
       'Your answers: <pre><code>' +
         JSON.stringify(result.value) +
        '</code></pre>',
      confirmButtonText: 'Lovely!'
    })
  }
})

我希望我可以将模态颜色更改为灰色

最佳答案

您必须在 Swal 函数中添加背景。它会为你工作。

Swal.mixin({
          input: "text",
          confirmButtonText: "Next &rarr;",
          showCancelButton: true,
          background: 'gray',
          progressSteps: ["1", "2", "3"]
        }) 
          .queue([
            {
              title: "Question 1",
              text: "Chaining swal2 modals is easy"
            },
            "Question 2",
            "Question 3"
          ])

          .then(result => {
            if (result.value) {
              Swal.fire({
                title: "All done!",
                 background: 'gray',
                html:
                  "Your answers: <pre><code>" +
                  JSON.stringify(result.value) +
                  "</code></pre>",
                confirmButtonText: "Lovely!"
              });
            }
          });

关于javascript - SweetAlert - 更改模式颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58353497/

相关文章:

javascript - sweetalert2:如何在重定向时拥有加载器动画

javascript - Sweet Alert 中使用 JSX 代替 HTML

php - 如何使用ajax从html获取数据并将数据传递到php

javascript - 为什么Bootstrap给col-lg-3不提

css - 当使用页面宽度时,它会向下跳转而不是创建水平溢出

html - 修复移动设备上动画下划线的宽度

javascript - 创建时用内容填充 w2ui

javascript - 运行调试器时回调未运行;

html - 搜索输入折叠

jquery - Sweetalert 2 异步文本区域