弹出居中iframe窗口,点击其它位置消失_html/css_WEB-ITnose
程序员文章站
2022-05-20 12:37:39
...
1.html
弹出详情
2.css
#myFrameId{ width:800px; height:600px; position: absolute; display:none;}
3.js
function detail(id){ $('#myFrameId').attr('src','https://www.baidu.com'); $('#myFrameId').show(); iframe_height = $(window).height()-600; iframe_width = $(document).width()-800; iframe_height>0?iframe_height=(iframe_height/2):iframe_height=0; iframe_width>0?iframe_width=(iframe_width/2):iframe_width=0; $('#myFrameId').css('top',iframe_height); $('#myFrameId').css('left',iframe_width);}$(document).on("click", function(e){ console.log('123'); $('#myFrameId').hide();});$(".myFrameId,.info_show").on("click", function(e){ console.log('456'); e.stopPropagation();});