SweetAlert-更改模式颜色

问题描述 投票:0回答:2

默认情况下,颜色为白色。可以更改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
2个回答
1
投票

您必须在Swal函数中添加background。它将为您工作。

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!"
              });
            }
          });
© www.soinside.com 2019 - 2024. All rights reserved.