Inicio
Comentar
Imágenes
Webgae
Modal multiple
HTML
Dismiss modal with a custom button
Dismiss modal with [×] button
Close
Dismiss with a custom button
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Top Tutorials jQuery Certificate W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. While using W3Schools, you agree to have read and accepted our terms of use, cookie and privacy policy. jQuery Certificate W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. While using W3Schools, you agree to have read and accepted our terms of use, cookie and privacy policy. Copyright 1999-2020 by Refsnes Data. All Rights Reserved. W3Schools is Powered by W3.CSS. W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. While using W3Schools, you agree to have read and accepted our terms of use, cookie and privacy policy. Copyright 1999-2020 by Refsnes Data. All Rights Reserved. W3Schools is Powered by W3.CSS.
×
Dismiss with [×] button
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Close
CSS
html { line-height: 1.5; font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif; font-weight: normal; color: rgba(0,0,0,0.87); } .modal { position: fixed; top: 0; left: 0; bottom: 0; right: 0; display: none; overflow: auto; background-color: #000000; background-color: rgba(0, 0, 0, 0.7); z-index: 9999; } .modal-window { position: relative; background-color: #FFFFFF; padding: 20px; } .modal-window.small { width: 75%; } .modal-window.large { width: 300px; } .close { position: absolute; top: 0; right: 0; color: rgba(0,0,0,0.3); height: 30px; width: 30px; font-size: 30px; line-height: 30px; text-align: center; } .close:hover, .close:focus { color: #000000; cursor: pointer; } .open { display: block; }
JavaScript
document.addEventListener('click', function (e) { e = e || window.event; var target = e.target || e.srcElement; if (target.hasAttribute('data-toggle') && target.getAttribute('data-toggle') == 'modal') { if (target.hasAttribute('data-target')) { var m_ID = target.getAttribute('data-target'); document.getElementById(m_ID).classList.add('open'); e.preventDefault(); } } // Close modal window with 'data-dismiss' attribute or when the backdrop is clicked if ((target.hasAttribute('data-dismiss') && target.getAttribute('data-dismiss') == 'modal') || target.classList.contains('modal')) { var modal = document.querySelector('[class="modal open"]'); modal.classList.remove('open'); e.preventDefault(); } }, false);
Puede cambiar código para ver el resultado
Resultado ↓
No hay comentarios:
Publicar un comentario
Entrada más reciente
Entrada antigua
Inicio
Suscribirse a:
Enviar comentarios (Atom)
No hay comentarios:
Publicar un comentario