【问题标题】:SweetAlert - Change modal colorSweetAlert - 更改模态颜色
【发布时间】:2019-10-12 11:11:19
【问题描述】:

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

我已经尝试用 CSS 来改变它,因为我关注另一个问题 herehere,就像这样:

.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!'
    })
  }
})

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

【问题讨论】:

    标签: javascript css sweetalert2


    【解决方案1】:

    你必须在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!"
                  });
                }
              });
    

    【讨论】:

    • 哇,好用,我已经阅读了文档,但我没有看到那个选项,或者我是否粗心:D,谢谢!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-01-07
    • 1970-01-01
    • 1970-01-01
    • 2020-01-21
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多