html+css+js气泡弹窗

界面 图片没截好,实际字是很清晰的

点赞加关注,谢谢

源代码

<!DOCTYPE html>

<html lang="en">

<head>

<meta charset="UTF-8">

<meta name="viewport" content="width=device-width, initial-scale=1.0">

<title>Popup Example</title>

<style>

body {

display: flex;

justify-content: center;

align-items: center;

height: 100vh;

margin: 0;

position: relative;

overflow: hidden;

}

.popup-container {

position: absolute;

top: 0;

left: 0;

width: 100%;

height: 100%;

display: flex;

justify-content: center;

align-items: flex-start;

visibility: hidden;

opacity: 0;

transition: visibility 0s 1.5s, opacity 1.5s;

z-index: 1000;

}

.popup-container.visible {

visibility: visible;

opacity: 1;

transition: visibility 0s, opacity 1.5s;

}

.popup {

background: rgba(255, 255, 255, 0.7);

border-radius: 10px;

box-shadow: 0 10px 20px rgba(0, 0, 0, 0.19), 0 6px 6px rgba(0, 0, 0, 0.23);

padding: 20px;

width: 300px;

max-height: 0;

overflow: hidden;

margin-top: 20px;

transition: max-height 0.5s ease-in-out, margin-top 0.5s ease-in-out;

}

.popup.open {

max-height: 400px;

margin-top: 0;

}

.popup-overlay {

position: absolute;

top: 0;

left: 0;

width: 100%;

height: 100%;

background: rgba(0, 0, 0, 0.5);

z-index: 999;

display: none;

}

.button {

border: none;

display: inline-block;

background: black;

color: white;

border-radius: 5px;

padding: 10px 20px;

margin-top: 10px;

cursor: pointer;

box-shadow: 0 2px 5px rgba(0, 0, 0, 0.26);

transition: box-shadow 0.3s ease-in-out;

}

.button:active {

box-shadow: none;

}

</style>

</head>

<body>

<button class="button" οnclick="togglePopup()">弹出</button>

<div class="popup-overlay" id="popupOverlay"></div>

<div class="popup-container" id="popupContainer">

<div class="popup" id="popup">

<p>微信安装完成,点击查看</p>

<!-- 注意:这里没有"确认"按钮,因为我们将使用延迟自动关闭 -->

</div>

</div>

<script>

function togglePopup() {

const popupContainer = document.getElementById('popupContainer');

const popup = document.getElementById('popup');

const popupOverlay = document.getElementById('popupOverlay');

// 添加类以显示弹出窗口和遮罩

popupContainer.classList.add('visible');

popup.classList.add('open');

popupOverlay.style.display = 'block';

// 设置1.5秒后自动关闭弹出窗口

setTimeout(() => {

popupContainer.classList.remove('visible');

popup.classList.remove('open');

popupOverlay.style.display = 'none';

}, 1500);

}

// 初始化时自动触发一次弹出窗口(如果需要)

// togglePopup(); // 取消注释以在页面加载时立即显示弹出窗口

</script>

</body>

</html>

相关推荐
EnoYao18 小时前
我写了一个团队体检报告 Skill,把摸鱼的同事扒出来了😅
前端·javascript
梁正雄18 小时前
Python前端-2-css练习
前端·css·python
Never_Satisfied18 小时前
在JavaScript / Node.js中,package.json文件中的依赖项自动选择最新版安装
javascript·node.js·json
蓝莓味的口香糖18 小时前
【vue3】组件的批量全局注册
前端·javascript·vue.js
Fighting_p20 小时前
【element UI】el-select 组件下拉数据某一行文字过多时,文字换行展示,避免el-select下拉框被撑宽,导致页面过丑
前端·javascript
未来之窗软件服务20 小时前
幽冥大陆(一百12)js打造json硬件管道——东方仙盟筑基期
开发语言·javascript·算法·json·仙盟创梦ide·东方仙盟·东方仙盟算法
王家视频教程图书馆20 小时前
vue3从本地选择一个视频 展示到视频组件中
前端·javascript·音视频
天外来鹿21 小时前
Map/Set/WeakMap/WeakSet学习笔记
前端·javascript·笔记·学习
Luna-player21 小时前
前端中stylus是干嘛用的
前端·css·stylus
紫_龙21 小时前
最新版vue3+TypeScript开发入门到实战教程之vue3与vue2语法优劣对比
前端·javascript·typescript