简体   繁体   English

如何在 SweetAlert2 处于活动状态时更改背景 (HTML)

[英]How to change the background (HTML) when a SweetAlert2 is active

I think this is a basic question for the SweetAlert2 active users, so, here we go:我认为这是 SweetAlert2 活跃用户的基本问题,所以,这里我们 go:

I have a SweetAlert2 ultra basic like this:我有一个像这样的超基本 SweetAlert2:

SA2

What I want to do is to change the background (of the HTML) when the SweetAlert2 is active, and when the SweetAlert2 is deactivated (clicking the 'OK' button) the backgruond returns to its original state:我想要做的是在 SweetAlert2 处于活动状态时更改(HTML 的)背景,当 SweetAlert2 被停用(单击“确定”按钮)时,背景返回到原来的 state:

在此处输入图像描述

It could be change the background with an image or color, but what I want to know is how to change it.可以用图像或颜色更改背景,但我想知道如何更改它。

If you want to change body background then document.querySelector('body').classList.add(yourCustomColorClassName) after deactiv alert document.querySelector('body').classList.remove(yourCustomColorClassName), if your want to change alert's ovarley's background then change (.swal2-container.swal2-backdrop-show, .swal2-container.swal2-noanimation) class in your css, it will back original background color after deactive alert.如果您想更改正文背景,那么 document.querySelector('body').classList.add(yourCustomColorClassName) 在停用警报 document.querySelector('body').classList.remove(yourCustomColorClassName) 之后,如果您想更改警报的 ovarley 的背景然后在您的 css 中更改 (.swal2-container.swal2-backdrop-show, .swal2-container.swal2-noanimation) class,它将在停用警报后返回原始背景颜色。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM