//添加权限模态框 function addRoleModal() { var $navPanelRight = $(".nav-panel-right") var $roleContent = $(".role-content") $roleContent.removeClass(‘hidden‘) $roleContent.css({ top : $navPanelRight.position().top + 200, left : $navPanelRight.position().left + 270 }); $navPanelRight.append(‘<div class="mymodal"></div>‘) $navPanelRight.addClass(‘nav-right-opacity‘) } //移除权限模态框 function removeRoleModal() { var $navPanelRight = $(".nav-panel-right") var $roleContent = $(".role-content") $roleContent.addClass(‘hidden‘) $(‘.mymodal‘).remove() $navPanelRight.removeClass(‘nav-right-opacity‘) }
<div class="role-content hidden"><img src="/resources/img/users/warn.png"/><p>此功能为园所会员功能,非园所会员无法使用。</p> <p>给您带来不便望请理解</p></div>
.role-content { width: 460px; height: 220px; position: absolute; background-color: #fff; opacity: 1; text-align: center; padding-top: 40px; box-shadow: 0px 5px 10px #d9d9d9; background-clip: padding-box; } .nav-right-opacity { opacity: 0.3; } .mymodal { position: fixed; top: 0; right: 0; bottom: 0; left: 0; z-index: 1050; overflow: hidden; -webkit-overflow-scrolling: touch; outline: 0; }
注意点:1、opacity设置后其子节点所有节点都是透明的
2、如果不想点击遮住的模态框,可以设置一个透明的遮罩层,就是上面的css .mymodal
3、自己对比下与bootstrap的区别吧
总结三点:1、父节点透明,2、弹出框在body下、3、加个透明层防止点击遮罩的div
时间: 2024-10-10 05:29:01