/* 模态框遮罩层 */
.modal-overlay {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.5);
display: flex;
align-items: center;
justify-content: center;
z-index: 1000;
overflow: auto;
}
/* 模态框容器 */
.modal {
background-color: #fff;
border-radius: 8px;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
width: 500px;
max-width: 90%;
animation: fadeIn 0.3s ease-out;
&.modal-sm {
width: 300px;
}
&.modal-lg {
width: 700px;
}
}
/* 模态框头部 */
.modal-header {
padding: 5px;
border-bottom: 1px solid #e0e0e0;
display: flex;
justify-content: space-between;
align-items: center;
h3 {
margin: 0;
font-size: 18px;
color: #333;
}
}
/* 关闭按钮 */
.close-button {
background: transparent;
border: none;
font-size: 20px;
cursor: pointer;
color: #888;
transition: color 0.3s;
&:hover {
color: #333;
}
}
/* 模态框主体 */
.modal-body {
padding: 15px;
color: #555;
max-height: 60vh;
overflow-y: auto;
}
/* 模态框底部 */
.modal-footer {
padding: 10px 15px;
border-top: 1px solid #e0e0e0;
display: flex;
justify-content: flex-end;
gap: 10px;
}
/* 按钮样式 */
.btn {
padding: 8px 16px;
border: none;
border-radius: 4px;
cursor: pointer;
font-size: 14px;
&.btn-secondary {
background-color: #f0f0f0;
color: #333;
&:hover {
background-color: #e0e0e0;
}
}
&.btn-primary {
background-color: #4CAF50;
color: #fff;
&:hover {
background-color: #45a049;
}
}
}
/* 动画效果 */
@keyframes fadeIn {
from {
opacity: 0;
transform: translateY(-20px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
这是封装的组件,如果想要调用,从父组件中引入即可,:visible绑定响应式变量,@close绑定关闭对话框事件。