Build Modal Css Code Example


Example 1: modal pop up html css

<button class="trigger">Click here to trigger the modal!</button>     <div class="modal">         <div class="modal-content">             <span class="close-button">×</span>             <h1>Hello, I am a modal!</h1>         </div>     </div>

Example 2: modal pop up html css

var modal = document.querySelector(".modal");     var trigger = document.querySelector(".trigger");     var closeButton = document.querySelector(".close-button");      function toggleModal() {         modal.classList.toggle("show-modal");     }      function windowOnClick(event) {         if (event.target === modal) {             toggleModal();         }     }      trigger.addEventListener("click", toggleModal);     closeButton.addEventListener("click", toggleModal);     window.addEventListener("click", windowOnClick);

Comments

Popular posts from this blog

Converting A String To Int In Groovy

"Cannot Create Cache Directory /home//.composer/cache/repo/https---packagist.org/, Or Directory Is Not Writable. Proceeding Without Cache"

Android How Can I Convert A String To A Editable