评论回复弹出遮罩效果实现思路兼容ie 8/chrome/f
网站建设 2023-01-28 20:48www.1681989.com免费网站
平日喜欢关注一些新闻,经常会浏览腾讯网!
很少看到评论的回复。与是仔细寻找之,发现原来是通过一个页面的弹出遮罩来显示的。
与是仔细研究一翻,自己模拟出来一个,感觉还行,兼容ie 8/chrome/firefox.
思路主页面和遮罩是两个不同的页面,遮罩通过iframe 利用js加载进来。
代码如下
dex.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://.w3./TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://.w3./1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<script type="text/javascript" src="http://ajax.googleapis./ajax/libs/jquery/1.7/jquery.m.js"></script>
<title>append-iframe</title>
<style type="text/css">
html,body{height:100%;paddg:0px;marg:0px;}
</style>
</head>
<body>
<div><put type="button" value="show" id="show-id"/></div>
<div><put type="button" value="test" id="test-id"/></div>
<script type="text/javascript">
$("#show-id").on("click",function(){
$(.document.body).append('<iframe src="subiframe.html" id="np-pop-iframe" allowtransparency="true" frameborder="0" scrollg="no" style="width: 100%; z-dex: 9999; position: fixed; : 0px; left: 0px; border: none; overflow: hidden; height: 100%;" data-nick="" data-pic="" data-id="" parentid=""></iframe>');
});
$("#test-id").on("click",function(){
alert("test");
});
</script>
</body>
</html>
subiframe.html:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://.w3./TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://.w3./1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<script type="text/javascript" src="http://ajax.googleapis./ajax/libs/jquery/1.7/jquery.m.js"></script>
<title>Document</title>
<style type="text/css">
html,body{height:100%;paddg:0px;marg:0px;}
.np-popframe-bg-opacity{
filter: alpha(opacity=50);
-moz-opacity: 0.5;
opacity: 0.5;
}
.wrapper{
position: absolute;
border:1px solid red;
width:800px;
height: 800px;
background: #fff;
:1000px;
left:500px;
}
</style>
</head>
<body class="iframe-body" style="background-image: none; width: 100%; height: 100%; background-position: itial itial; background-repeat: itial itial;">
<div class="np-popframe-bg-opacity" style="height: 100%; width:100%; background-color:#000;"></div>
<div class="np-popframe-bg" id="np-popframe-bg-id" style="height: 100%; width:100%; position:absolute; :0px; left:0px;"></div>
<div class="wrapper" id="wrapper-id"></div>
</body>
<script type="text/javascript">
(function(){
$("#wrapper-id").animate({:"100px"},"slow");
$("#np-popframe-bg-id").on("click",function(){
//$(wdow.parent.document.getElementById("np-pop-iframe")).remove();
$("#np-pop-iframe",wdow.parent.document).remove();
});
})(jQuery);
</script>
</html>
这里需要用一到滤镜。让加载来的遮罩保持透明.
1 np-popframe-bg-id 的作用主要是显示评论框的外部区域。当鼠标点击该区域的时候,移除iframe.
2 div 需要设置100%的高度,需要在前面加上 html,body{height:100%;}的css,否则无效
3 还有一点就是绝对定位的absolute.
偶有所得,以记录之,谨防忘记!
很少看到评论的回复。与是仔细寻找之,发现原来是通过一个页面的弹出遮罩来显示的。
与是仔细研究一翻,自己模拟出来一个,感觉还行,兼容ie 8/chrome/firefox.
思路主页面和遮罩是两个不同的页面,遮罩通过iframe 利用js加载进来。
代码如下
dex.html
复制代码
代码如下:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://.w3./TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://.w3./1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<script type="text/javascript" src="http://ajax.googleapis./ajax/libs/jquery/1.7/jquery.m.js"></script>
<title>append-iframe</title>
<style type="text/css">
html,body{height:100%;paddg:0px;marg:0px;}
</style>
</head>
<body>
<div><put type="button" value="show" id="show-id"/></div>
<div><put type="button" value="test" id="test-id"/></div>
<script type="text/javascript">
$("#show-id").on("click",function(){
$(.document.body).append('<iframe src="subiframe.html" id="np-pop-iframe" allowtransparency="true" frameborder="0" scrollg="no" style="width: 100%; z-dex: 9999; position: fixed; : 0px; left: 0px; border: none; overflow: hidden; height: 100%;" data-nick="" data-pic="" data-id="" parentid=""></iframe>');
});
$("#test-id").on("click",function(){
alert("test");
});
</script>
</body>
</html>
subiframe.html:
复制代码
代码如下:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://.w3./TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://.w3./1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<script type="text/javascript" src="http://ajax.googleapis./ajax/libs/jquery/1.7/jquery.m.js"></script>
<title>Document</title>
<style type="text/css">
html,body{height:100%;paddg:0px;marg:0px;}
.np-popframe-bg-opacity{
filter: alpha(opacity=50);
-moz-opacity: 0.5;
opacity: 0.5;
}
.wrapper{
position: absolute;
border:1px solid red;
width:800px;
height: 800px;
background: #fff;
:1000px;
left:500px;
}
</style>
</head>
<body class="iframe-body" style="background-image: none; width: 100%; height: 100%; background-position: itial itial; background-repeat: itial itial;">
<div class="np-popframe-bg-opacity" style="height: 100%; width:100%; background-color:#000;"></div>
<div class="np-popframe-bg" id="np-popframe-bg-id" style="height: 100%; width:100%; position:absolute; :0px; left:0px;"></div>
<div class="wrapper" id="wrapper-id"></div>
</body>
<script type="text/javascript">
(function(){
$("#wrapper-id").animate({:"100px"},"slow");
$("#np-popframe-bg-id").on("click",function(){
//$(wdow.parent.document.getElementById("np-pop-iframe")).remove();
$("#np-pop-iframe",wdow.parent.document).remove();
});
})(jQuery);
</script>
</html>
这里需要用一到滤镜。让加载来的遮罩保持透明.
1 np-popframe-bg-id 的作用主要是显示评论框的外部区域。当鼠标点击该区域的时候,移除iframe.
2 div 需要设置100%的高度,需要在前面加上 html,body{height:100%;}的css,否则无效
3 还有一点就是绝对定位的absolute.
偶有所得,以记录之,谨防忘记!
网站设计
- 静宁会SEO的网站建设公司:全面提升您的网络影
- 提升在线业务的关键:选择最佳的丽水网站建设
- 浙江网站优化发展潜力如何
- 井研专业的网站建设公司:打造您的在线品牌
- 灵山SEO网站建设公司:提升您的在线业务表现
- 蒙城网站建设优化公司:提升您网站表现的理想
- 阳谷企业网站优化:提升线上业务力的关键
- 樟树专业的网站建设公司:打造您在线业务的坚
- 通河百度SEO排名的策略与技巧
- 重庆百度快照排名如何进行精准的客户引流
- 重庆百度快照排名
- 常宁便宜的建站公司:助您轻松打造在线业务
- 巫溪百度网站优化:提升网站曝光率与流量的关
- 湖北整站优化怎么做才能放大客户需求
- 闸北网站建设多少钱?全面解析与预算规划
- 辽宁企业网站优化怎么做电话营销