Created
March 9, 2023 21:58
-
-
Save perseoq/e871d2a0e99ad43367bd144858012cd8 to your computer and use it in GitHub Desktop.
modal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>Document</title> | |
</head> | |
<body> | |
<button id="myBtn">Abrir ventana modal</button> | |
<div id="myModal" class="modal"> | |
<div class="modal-content"> | |
<span class="close">×</span> | |
<p> | |
<h1>Formulario</h1> | |
<form action="algo.src" method="post"> | |
kkk <br> | |
<input type="text"> <br> | |
dldldl <br> | |
<input type="text"> | |
<input type="submit" value="Enviar"> | |
</form> | |
</p> | |
</div> | |
<style> | |
.modal { | |
display: none; | |
position: fixed; | |
z-index: 1; | |
left: 0; | |
top: 0; | |
width: 100%; | |
height: 100%; | |
overflow: auto; | |
background-color: rgba(0,0,0,0.4); | |
} | |
.modal-content { | |
background-color: #fefefe; | |
margin: 15% auto; | |
padding: 20px; | |
border: 1px solid #888; | |
width: 80%; | |
} | |
.close { | |
color: #aaaaaa; | |
float: right; | |
font-size: 28px; | |
font-weight: bold; | |
} | |
.close:hover, | |
.close:focus { | |
color: #000; | |
text-decoration: none; | |
cursor: pointer; | |
} | |
</style> | |
<script> | |
var modal = document.getElementById("myModal"); | |
var btn = document.getElementById("myBtn"); | |
var span = document.getElementsByClassName("close")[0]; | |
btn.onclick = function() { | |
modal.style.display = "block"; | |
} | |
span.onclick = function() { | |
modal.style.display = "none"; | |
} | |
window.onclick = function(event) { | |
if (event.target == modal) { | |
modal.style.display = "none"; | |
} | |
} | |
</script> | |
</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment