最新文章专题视频专题问答1问答10问答100问答1000问答2000关键字专题1关键字专题50关键字专题500关键字专题1500TAG最新视频文章推荐1 推荐3 推荐5 推荐7 推荐9 推荐11 推荐13 推荐15 推荐17 推荐19 推荐21 推荐23 推荐25 推荐27 推荐29 推荐31 推荐33 推荐35 推荐37视频文章20视频文章30视频文章40视频文章50视频文章60 视频文章70视频文章80视频文章90视频文章100视频文章120视频文章140 视频2关键字专题关键字专题tag2tag3文章专题文章专题2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章专题3
当前位置: 首页 - 科技 - 知识百科 - 正文

jQuery做出页面遮罩层效果

来源:懂视网 责编:小采 时间:2020-11-27 19:53:00
文档

jQuery做出页面遮罩层效果

jQuery做出页面遮罩层效果:这次给大家带来jQuery做出页面遮罩层效果,jQuery做出页面遮罩层效果的注意事项有哪些,下面就是实战案例,一起来看一下。<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <
推荐度:
导读jQuery做出页面遮罩层效果:这次给大家带来jQuery做出页面遮罩层效果,jQuery做出页面遮罩层效果的注意事项有哪些,下面就是实战案例,一起来看一下。<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <

这次给大家带来jQuery做出页面遮罩层效果,jQuery做出页面遮罩层效果的注意事项有哪些,下面就是实战案例,一起来看一下。

<!DOCTYPE html>
<html>
 <head>
 <meta charset="UTF-8">
 <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
 <meta name="apple-mobile-web-app-capable" content="yes">
 <meta name="apple-mobile-web-app-status-bar-style" content="black">
 <meta name="description" content="aportpower"/>
 <title>遮罩层</title>
 <style type="text/css">
 .fh-link-bar {
 border-top: none;
 }
 .fh-link-bar {
 background-color: #fff;
 border: 1px solid #eaeaea;
 border-left: none;
 border-right: none;
 padding: 10px;
 height: 50px;
 line-height: 30px;
 font-size: 14px;
 }
 #personsex{
 float: right;
 }
 .personsex {
 background: magenta;
 width: 150px;
 height: 180px;
 line-height: 40px;
 text-align: center;
 border-radius: 2px;
 z-index: 104; /*层级关系为104*/
 /*只是用来控制位置的*/
 position: absolute;
 margin: 100px auto;
 font-size: 20px;
 left: 0;
 right: 0;
 top: 0;
 bottom: 0;
 }
 /*一定要记得添加样式(必须)*/
 .loading-shade {
 position: fixed; /*窗口定位*/
 background: rgba(0,0,0,.5); /*遮罩层的颜色*/
 z-index: 102; /*层级关系为102*/
 }
 .loading-shade{
 height: 100%;
 width: 100%;
 top: 0;
 left: 0;
 }
 </style>
 </head>
 <body>
 <!--页面上原先有的内容(用来执行点击)-->
 <section class="fh-link-bar" id="sexlog">
 <span>性别</span>
 <span class="fh-data" id="personsex">男</span>
 </section>
 <!--页面上原先没有的内容(用来执行点击后生成的提示框)-->
 <p class="personsex" style="display: none;">
 <p>保密</p>
 <p>男</p>
 <p>女</p>
 </p>
 </body>
 <script src="jquery-1.7.2.min.js"></script>
 <script type="text/javascript">
 //添加页面遮罩
 function addShade() {
 var htmlHeight = document.body.scrollHeight || document.documentElement.scrollHeight;
 $("body").append('<p class="loading-shade"></p>');
 //$(".loading-shade").css("height",htmlHeight+"px");
 $(".loading-shade").css("100%");
 }/*删除页面遮罩*/
 function removeShade() {
 $(".loading-shade").remove();
 }
 /*页面遮罩点击关闭弹出层
 * dom=>#id
 * type => hide || remove
 * */
 function closep(dom, type) {
 $(".loading-shade").click(function() {
 type == "hide" ? $(dom).hide() : $(dom).remove();
 $(".loading-shade").remove();
 })
 }
 //需要调用的页面添加的js(这里是点击上边的p(即:.personsex p元素)的时候实现遮罩层消失。)
// $('#sexlog,#personsex').unbind("click").bind("click",function(){
// addShade();
// $('.personsex').show();
// });
//
// $('.personsex p').bind('click',function(){
// $('.loading-shade').remove();
// $('.personsex').hide();
// });
 //======================================================================================
 //需要调用的页面添加的js(这里是点击遮罩层实现遮罩层(即:.loading-shade)页面关闭)
 $('#sexlog,#personsex').unbind("click").bind("click",function(){
 addShade();
 $('.personsex').show();
 del();
 });
 function del(){
 $('.loading-shade').bind('click',function(){
 $('.loading-shade').remove();
 $('.personsex').hide();
 });
 }
 </script>
</html>

相信看了本文案例你已经掌握了方法,更多精彩请关注Gxl网其它相关文章!

推荐阅读:

jQuery的prev()使用详解

jquery+ajax实现异步提交表单数据

jQuery实现图标显示隐藏切换

用jQuery实现在前端搜索

文档

jQuery做出页面遮罩层效果

jQuery做出页面遮罩层效果:这次给大家带来jQuery做出页面遮罩层效果,jQuery做出页面遮罩层效果的注意事项有哪些,下面就是实战案例,一起来看一下。<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <
推荐度:
标签: 页面 网页 实现
  • 热门焦点

最新推荐

猜你喜欢

热门推荐

专题
Top