js实现广告弹窗
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> </head> <style> .adver{ width: 300px; height: 200px; border: 1px solid #ccc; background-color: pink; position: absolute; top: 100px; right: 0; } span{ width: 40px; height: 25px; position: absolute; top: 0; right: 0; background-color: #ccc; color: #fff; text-align: center; } </style> <body> <div class="adver"> <span>关闭</span> </div> </body> <script> // 获取操作对象 var adver = document.querySelector('.adver'); //延迟消失 // setTimeout(function(){ // // 让div消失 // //display:none opacity:0 right:-300px // adver.style.display = 'none' // },3000) var span = document.querySelector('span'); // 给操作对象添加事件 span.onclick = function(){ // 当点击关闭按钮让整个盒子隐藏 adver.style.display = 'none' // 设置延时定时器 setTimeout(function(){ adver.style.display = 'block' },3000) } </script> </html>
效果图:点击关闭即可隐藏 - 3秒过后既又重新出现
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
· 单元测试从入门到精通