sweetAlert1不像sweetAlert2那樣可以通過width屬性來配置彈窗的寬度。但是可以通過customClass屬性來配置自定義樣式
1、如何使用自定義樣式
swal({ title: "漂亮!", text: "這是自定義圖標。", imageUrl: "images/thumbs-up.jpg" , customClass: "sweetAlert sweetAlert2" });
其中的sweetAlert和sweetAlert2就是在CSS樣式中定義的樣式類,多個類中間使用空格隔開
2、使用自定義樣式設置彈窗的寬度
.sweetAlert { width: 22em; margin: 0 auto; left: 0; right: 0; }