平台怎样实现全局动态弹窗
画面管理
-
想让画面支持下面自定义的风格和弹窗
<head>
<style>
/* 提示框样式 */
.alert-box {
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
padding: 20px 40px;
background-color: rgba(0, 0, 0, 0.8);
color: white;
border-radius: 8px;
font-family: Arial, sans-serif;
font-size: 16px;
z-index: 1000;
opacity: 0;
animation: fadeInOut 3s;
}/* 淡入淡出动画 */ @keyframes fadeInOut { 0% { opacity: 0; } 15% { opacity: 1; } 85% { opacity: 1; } 100% { opacity: 0; } } </style>
</head>
<body>
<!-- 示例按钮 -->
<button onclick="showAlert('操作成功!', 2000)">显示提示</button><script> function showAlert(message, duration = 2000) { // 创建提示框元素 const alertBox = document.createElement('div'); alertBox.className = 'alert-box'; alertBox.textContent = message; // 添加到页面 document.body.appendChild(alertBox); // 自动移除 setTimeout(() => { alertBox.remove(); }, duration); } </script>
</body>
应该怎样操作