<div class="modal-demo">
<button class="open-modal-btn" onclick="openModal('modal1')">Abrir Modal</button>
<div id="modal1" class="modal-overlay">
<div class="modal-content">
<div class="modal-header">
<h3>Título del Modal</h3>
<button class="close-btn" onclick="closeModal('modal1')">×</button>
</div>
<div class="modal-body">
<p>Este es el contenido del modal. Puedes agregar cualquier contenido aquí.</p>
<form class="modal-form">
<input type="text" placeholder="Nombre" required>
<input type="email" placeholder="Email" required>
<textarea placeholder="Mensaje"></textarea>
</form>
</div>
<div class="modal-footer">
<button class="btn-secondary" onclick="closeModal('modal1')">Cancelar</button>
<button class="btn-primary">Guardar</button>
</div>
</div>
</div>
</div>
.modal-demo {
padding: 2rem;
text-align: center;
}
.open-modal-btn {
padding: 1rem 2rem;
background: #3b82f6;
color: white;
border: none;
border-radius: 8px;
font-size: 1rem;
font-weight: 600;
cursor: pointer;
transition: all 0.3s ease;
}
.open-modal-btn:hover {
background: #2563eb;
transform: translateY(-2px);
box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}
.modal-overlay {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.5);
display: flex;
align-items: center;
justify-content: center;
opacity: 0;
visibility: hidden;
transition: all 0.3s ease;
z-index: 1000;
}
.modal-overlay.active {
opacity: 1;
visibility: visible;
}
.modal-content {
background: white;
border-radius: 12px;
max-width: 500px;
width: 90%;
max-height: 80vh;
overflow-y: auto;
transform: scale(0.7);
transition: transform 0.3s ease;
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}
.modal-overlay.active .modal-content {
transform: scale(1);
}
.modal-header {
display: flex;
justify-content: space-between;
align-items: center;
padding: 1.5rem;
border-bottom: 1px solid #e5e7eb;
}
.modal-header h3 {
margin: 0;
font-size: 1.25rem;
font-weight: 600;
color: #1f2937;
}
.close-btn {
background: none;
border: none;
font-size: 1.5rem;
cursor: pointer;
color: #6b7280;
padding: 0;
width: 30px;
height: 30px;
display: flex;
align-items: center;
justify-content: center;
border-radius: 50%;
transition: all 0.2s ease;
}
.close-btn:hover {
background: #f3f4f6;
color: #374151;
}
.modal-body {
padding: 1.5rem;
}
.modal-form {
display: flex;
flex-direction: column;
gap: 1rem;
margin-top: 1rem;
}
.modal-form input,
.modal-form textarea {
padding: 0.75rem;
border: 1px solid #d1d5db;
border-radius: 6px;
font-size: 1rem;
transition: border-color 0.2s ease;
}
.modal-form input:focus,
.modal-form textarea:focus {
outline: none;
border-color: #3b82f6;
box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}
.modal-footer {
display: flex;
justify-content: flex-end;
gap: 1rem;
padding: 1.5rem;
border-top: 1px solid #e5e7eb;
}
.btn-secondary {
padding: 0.75rem 1.5rem;
background: #f3f4f6;
color: #374151;
border: none;
border-radius: 6px;
font-weight: 500;
cursor: pointer;
transition: background 0.2s ease;
}
.btn-secondary:hover {
background: #e5e7eb;
}
.btn-primary {
padding: 0.75rem 1.5rem;
background: #3b82f6;
color: white;
border: none;
border-radius: 6px;
font-weight: 500;
cursor: pointer;
transition: background 0.2s ease;
}
.btn-primary:hover {
background: #2563eb;
}