使用 css 居中 sweetalert 文本

Eli*_*ias 1 javascript css sweetalert

我试图将文本放在我的 swal-box 中,但它不起作用:

CSS3:

.swal-modal {
    text-align: center;
}
Run Code Online (Sandbox Code Playgroud)

JavaScript:

swal("myTitle", "some text \n some more text \n even more text);
Run Code Online (Sandbox Code Playgroud)

小智 8

您可以在 swal-modal 中使用 css 将文本居中

.swal-modal .swal-text {
    text-align: center;
}
Run Code Online (Sandbox Code Playgroud)