亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

div 內的 SweetAlert2

div 內的 SweetAlert2

慕森卡 2023-07-20 16:06:10
我遇到了同樣的問題,我希望在 div 中包含 sweetalert2 (不是 sweetalert toast),因為我希望除它之外的另一個 div 在彈出 sweetalert 時可以滾動。我已經嘗試過上面的代碼,但它仍然無法正常工作。var id = document.getElementById('mydiv');swal({title: "question",target: id,showConfirmButton: false,showCloseButton: true,allowOutsideClick: false,allowEscapeKey : false,customClass: "swal-height"});我也有固定的CSS定位#mydiv{? overflow: hidden;? height: calc(100% - 300px) !important;? padding-bottom: 70px;? position: relative !important;}#mydiv .swal-height {? ? position:absolute !important;? ? height: 720px !important;? ? width: 780px !important;? ? margin-left: 1100px !important;? ? margin-top: 280px !important;}你能建議我在這里做錯了什么嗎?這是 JSFiddle,它與我正在構建的類似: https:?//jsfiddle.net/0pt2vr87/7/感謝您的幫助。
查看完整描述

1 回答

?
隔江千里

TA貢獻1906條經驗 獲得超10個贊

您customClass錯誤地使用了參數,它應該是一個對象,而不是字符串。


Swal.fire({

? text: 'Modal inside a custom target',

? target: '#custom-target',

? customClass: {? ? ? ? ? ? ? ? ? ? ? // <------ customClass is an object!

? ? container: 'position-absolute'

? },

})

#custom-target {

? position: relative;

? width: 300px;

? height: 200px;

? border-style: solid;

}


.position-absolute {

? position: absolute !important;

}

<script src="https://cdn.jsdelivr.net/npm/sweetalert2@10"></script>?


<div id="custom-target"></div>

查看完整回答
反對 回復 2023-07-20
  • 1 回答
  • 0 關注
  • 140 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號