目前我正在為我的系統制作自己的模式。當您單擊包的名稱時,會彈出并顯示模式。我添加了一些 JQuery,當單擊背景時應該刪除模式。它確實做到了這一點,但當我單擊模式本身時它也會隱藏。我嘗試將 z-index 3 添加到父級,將 z-index 4 添加到模態,但這不起作用。我怎樣才能做到這樣,如果單擊背景,模式會消失,但當單擊模式本身時,它不會執行任何操作,并且人們可以與模式正常交互?我有一個小插圖https://i.stack.imgur.com/mFEn1.gif 超文本標記語言薩斯.package-popup position: fixed top: 0 left: 0 height: 100% width: 100% display: none overflow: hidden background-color: $primary_background_transparent z-index: 3 .package-popup-dialog max-width: 960px position: relative margin: auto top: 100px background-color: $color-white border-radius: 16px padding: 3rem z-index: 4 pointer-events: none .package-popup-content position: relative pointer-events: auto display: flex flex-direction: column
1 回答

犯罪嫌疑人X
TA貢獻2080條經驗 獲得超4個贊
只需檢查點擊事件目標:
$(item).on('click', function(event) {
if (event.target.classList.contains("shadow")) {
// Close dialog
}
}
從 css 中刪除pointer-events: none以使其正常工作
- 1 回答
- 0 關注
- 91 瀏覽
添加回答
舉報
0/150
提交
取消