vue自定义弹出层、vue自定义弹出框、vue上下左右居中弹出框
可直接拿去用,如果需要两个按钮,需自己手动添加
css
/* 弹窗样式 */ .login { position: fixed; height: 100px; width: 240px; background: #ffffff; border-radius: 0.25rem; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 1000; } .over { position: fixed; width: 100%; height: 100%; opacity: 0.2; filter: alpha(opacity=20); top: 0; left: 0; z-index: 999; background-color: #111111; } .popup_content{ width: 90%; margin: auto; text-align: center; position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); margin-top: -10px; } .close_popup_btn{ width: 100%; height: 30px; line-height: 30px; text-align: center; position: absolute; left: 0; bottom: 0; border-top: 1px solid #eee; }
html
<button @click="ShowPopup" style="width: 2rem;height: 0.6rem;line-height: 0.6rem;text-align: center;background: chartreuse;">自定义弹窗</button> <div v-show="is_popup"> <!--这里是要展示的内容层--> <div class="login"> <p class="popup_content">这是提示内容</p> <div class="close_popup_btn" @click="close_popup_btn">确定</div> </div> <!--这里是半透明背景层--> <div class="over"></div> </div>
js
data() { return { is_popup:false, } }, methods: { ShowPopup(){ this.is_popup=true }, close_popup_btn(){ this.is_popup=false }, },
效果图
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· DeepSeek 开源周回顾「GitHub 热点速览」
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了