Heim > Fragen und Antworten > Hauptteil
P粉9860280392023-09-01 18:38:39
尽管它可能无法将按钮放置在您想要的确切位置,但您始终可以将对话框的边框和背景设置为透明。然后在里面有一个 div,你将其设置为看起来像一个对话框。并将按钮放在对话框本身内。这将使按钮看起来像在对话框之外,但仍然允许您访问它。不过,您将需要弄乱尺寸和绝对定位。
const favDialog = document.querySelector('.modal-post'); const showButton = document.querySelector('#showButton'); const nextButton = document.querySelector('.next-modal-button'); showButton.addEventListener('click', () => { favDialog.showModal(); }); nextButton.addEventListener('click', () => { console.log("NEXT"); });
.modal-post { border:0; background:transparent; height:100% } .next-modal-button { position: absolute; width: 60px; height: 30px; color: black; bottom: 20px; right: 10px; z-index: 1000; } .modal-body{ background:#fff; border:1px solid #000; padding:10px; width: 500px; height: 280px; }
<dialog class="modal-post" ref="postModalRef"> <div class="modal-body">Modal screen</div> <button class="next-modal-button" @click="displayNextModal">Next</button> </dialog> <button id="showButton">Show</button>