<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Top Popup</title>
<style>
.popup {
position: fixed;
top: -50px;
left: 50%;
transform: translateX(-50%);
width: 300px;
padding: 20px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
transition: top 0.3s ease-in-out;
background-color: white;
}
.show {
top: 0;
}
</style>
</head>
<body>
<div id="myPopup" class="popup">
Welcome to my Popup!
<button onclick="document.getElementById('myPopup').classList.remove('show')">Close</button>
</div>
<button onclick="document.getElementById('myPopup').classList.add('show')">Show Popup</button>
</body>
</html>
html实现顶部弹出
于 2024-03-19 17:03:15 首次发布