首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >SweetAlert -改变模态颜色

SweetAlert -改变模态颜色
EN

Stack Overflow用户
提问于 2019-10-12 11:11:19
回答 1查看 4.5K关注 0票数 1

默认情况下,颜色是白色。是否可以改变sweetalert2的模态背景色?

我试着用CSS来改变它,就像我接着问这里这里的另一个问题,如下所示:

代码语言:javascript
运行
复制
.sweet-alert 
{
   background-color: #2f2f2f96;
}

但我什么都没有,

我使用甜警报问题功能

代码语言:javascript
运行
复制
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!'
    })
  }
})

我希望我能把模式颜色改成灰色。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-10-12 11:34:34

您必须在Swal函数中添加背景。它会对你有用的。

代码语言:javascript
运行
复制
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!"
              });
            }
          });
票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/58353497

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档