该用户从未签到
|
发表于 2023-11-23 23:01:00
来自手机
|
显示全部楼层
```html
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>我爱你弹窗</title>
<style>
.popup {
display: none;
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background-color: white;
border: 1px solid #ccc;
padding: 20px;
z-index: 1000;
}
.overlay {
display: none;
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.5);
z-index: 999;
}
</style>
</head>
<body>
<div class="overlay" id="overlay"></div>
<div class="popup" id="popup">
<p>我爱你!</p>
<button onclick="closePopup()">关闭</button>
</div>
<script>
function showPopup() {
document.getElementById('popup').style.display = 'block';
document.getElementById('overlay').style.display = 'block';
}
function closePopup() {
document.getElementById('popup').style.display = 'none';
document.getElementById('overlay').style.display = 'none';
}
setTimeout(showPopup, 3000); // 3秒后显示弹窗
</script>
</body>
</html>
``` |
|