【javascript】上拉下拉弹窗实现
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>Document</title> <link rel="stylesheet" href="./css/slidepopup.css"> <script> //->REM ~function () { var desW = 750, winW = document.documentElement.clientWidth || document.body.clientWidth; if (winW > desW) { return; } document.documentElement.style.fontSize = winW / desW * 100 + 'px'; }(); </script> </head> <body> <div class="btn">按钮</div> <div class="promote_mask"> <div> <div class="clear operate"> <span class="f_left cancel">取消</span> <span class="f_left title">上传图片</span> <span class="f_left determine">确定</span> </div> <div class="picture_area"> <p class="tips">请上传符合任务要求的图片</p> <div class="picture_wrapper"> <div class="progress">0%</div> <input id="upload_input_again" type="file" accept="image/*" capture="camera" /> </div> <p>图片大小不超过2M,仅支持jpg、png、jpeg</p> </div> </div> </div> <script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.js"></script> <script> $(function(){ //点击按钮 $(".btn").click(function(){ $(".promote_mask").show(); $(".promote_mask>div").slideToggle(); }) $(".promote_mask").click(function(e){ var event = e || window.event; var target = event.target || event.srcElement; if(target.className == "promote_mask"){ $(".promote_mask>div").slideToggle(function(){ $(".promote_mask").hide(); }); } }) // 取消 $(".cancel").click(function(){ $(".promote_mask>div").slideToggle(function(){ $(".promote_mask").hide(); }); }); }) </script> </body> </html>
html, body { height: 100%; max-height: 100%; font-size: 100px; background: #fff; } .promote_mask,.seeimg_mask{ position: fixed; top:0; left:0; right:0; display: none; margin:0 auto; width:7.5rem; height:100%; background:rgba(0,0,0,0.6); z-index:2; } .promote_mask>div{ position:fixed; bottom:0; left:0; right:0; margin: 0 auto; display: none; width:100%; height:5.78rem; z-index:3; background:#fff; } .seeimg_mask>div{ position:fixed; bottom:0; left:0; right:0; margin: 0 auto; display: none; width:100%; height:4.78rem; z-index:3; background:#fff; } .promote_mask .operate{ padding:0 0.3rem; width: 100%; height:0.88rem; font-size:0.32rem; border-bottom: 1px solid #D9D9D9; box-sizing: border-box; } .promote_mask .operate span{ display: block; width:1rem; height:0.88rem; font-family:PingFang-SC-Bold; color:#666; font-weight: 400; line-height:0.88rem; text-align: left; } .promote_mask .operate .title{ width:4.9rem; font-weight:bold; color:rgba(51,51,51,1); text-align: center; } .promote_mask .operate .determine{ color:#FF6602; text-align: right; } .promote_mask .picture_area{ padding:0.26rem 0 0.42rem; text-align: center; box-sizing: border-box; } .seeimg_mask .picture_area{ padding:0.26rem; text-align: center; box-sizing: border-box; } .promote_mask .picture_area p{ height:0.34rem; font-size:0.24rem; font-family:PingFang-SC-Medium; font-weight:500; color:rgba(153,153,153,1); line-height:0.34rem; } .seeimg_mask .picture_area p{ height:0.34rem; font-size:0.24rem; font-family:PingFang-SC-Medium; font-weight:500; color:rgba(153,153,153,1); line-height:0.34rem; } .promote_mask .picture_area .tips{ height:0.4rem; font-size:0.28rem; font-family:PingFang-SC-Bold; font-weight:bold; color:rgba(51,51,51,1); line-height:0.4rem; } .seeimg_mask .picture_area .tips{ height:0.4rem; font-size:0.28rem; font-family:PingFang-SC-Bold; font-weight:bold; color:rgba(51,51,51,1); line-height:0.4rem; text-align: center; } .seeimg_mask .close{ width: 0.48rem; height: 0.48rem; margin-right: 0.16rem; background: url("../images/close.png") no-repeat; background-size: 100% 100%; position: absolute; right: 0.2rem; top: 0.2rem; } .promote_mask .picture_area .picture_wrapper{ position: relative; margin:0.28rem auto 0.2rem; width:4.6rem; height:3rem; background:rgba(255,255,255,1); box-sizing: border-box; /* border:1px dashed #f0f0f0; */ } .promote_mask .picture_area .picture_wrapper #upload_input_again{ display: block; width: 100%; height: 100%; opacity: 0; -webkit-tap-highlight-color: transparent; } .seeimg_mask .picture_area .picture_wrapper{ position: relative; margin:0.28rem auto 0.2rem; width:4.6rem; height:3rem; background:rgba(255,255,255,1); box-sizing: border-box; } .promote_mask .picture_area .picture_wrapper .progress{ position:absolute; top:0; left:0; width:100%; height:100%; display: none; font-size:0.32rem; line-height: 3rem; color:#fff; text-align: center; }
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· AI 智能体引爆开源社区「GitHub 热点速览」
· 三行代码完成国际化适配,妙~啊~
· .NET Core 中如何实现缓存的预热?