本文介绍了Swal警报打开大弹出然后屏幕的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用swal弹出窗口。但它是开放的大弹出窗口。
i不要如何设置swal警报的高度。
我尝试过:
i am using swal popup. but it's open big popup.
i dont no how to set height of swal alert.
What I have tried:
<script src="~/Dist/sweetalert.min.js"></script>
<link href="~/Dist/sweetalert.css" rel="stylesheet" />
<a class="btn btn-success block" id="BlockUnblockBtn" onclick="BlockUnblock(this,event);">Block</a>
function BlockUnblock(ctl, event) {
swal({
title: "Are you sure?",
text: "You will not be able to recover this imaginary file!",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Yes, delete it!",
cancelButtonText: "No, cancel plx!",
closeOnConfirm: false,
closeOnCancel: false
},
function (isConfirm) {
if (isConfirm) {
swal("Deleted!", "Your imaginary file has been deleted.", "success");
} else {
swal("Cancelled", "Your imaginary file is safe :)", "error");
}
});
}
推荐答案
customClass: swal-size-sm
然后创建CSS:
Then create CSS:
.swal-size-sm
{
width: 200px !important;
}
...不要忘记!important,以便它会覆盖swal的默认大小。 ^ _ ^
...don't forget the "!important" so that it would overwrite the default size of swal. ^_^
<!DOCTYPE html>
<html lang="en">
<head>
<script src="https://unpkg.com/sweetalert/dist/sweetalert.min.js"></script>
<style>
.myClass{
width:400px;
height:200px;
}
</style>
</head>
<body>
<script>
swal({
title: "Are you sure?",
text: "You will not be able to recover this imaginary file!",
className: "myClass",
});
</script>
</body>
</html>
这篇关于Swal警报打开大弹出然后屏幕的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!