小男孩‘自慰网亚洲一区二区,亚洲一级在线播放毛片,亚洲中文字幕av每天更新,黄aⅴ永久免费无码,91成人午夜在线精品,色网站免费在线观看,亚洲欧洲wwwww在线观看

分享

JS彈窗 JS彈出DIV并使整個(gè)頁(yè)面背景變暗功能的實(shí)現(xiàn)代碼

 instl 2019-08-03

JS彈窗 JS彈出DIV并使整個(gè)頁(yè)面背景變暗功能的實(shí)現(xiàn)代碼

 更新時(shí)間:2018年04月21日 14:05:35   作者:下頁(yè)、再停留   我要評(píng)論

這篇文章主要介紹了JS彈窗 JS彈出DIV并使整個(gè)頁(yè)面背景變暗功能的實(shí)現(xiàn)代碼,需要的朋友可以參考下

1.首先寫(xiě)一個(gè)遮罩層div,然后再寫(xiě)一個(gè)彈窗的div

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<!-- 遮罩層 -->
<div id="cover" style="background: #000; position: absolute; left: 0px; top: 0px; width: 100%; filter: alpha(opacity=30); opacity: 0.3; display: none; z-index: 2 ">
   
</div>
<!-- 彈窗 -->
<div id="showdiv" style="width: 80%; margin: 0 auto; height: 9.5rem; border: 1px solid #999; display: none; position: absolute; top: 40%; left: 10%; z-index: 3; background: #fff">
  <!-- 標(biāo)題 -->
  <div style="background: #F8F7F7; width: 100%; height: 2rem; font-size: 0.65rem; line-height: 2rem; border: 1px solid #999; text-align: center;" >
    提示
  </div>
  <!-- 內(nèi)容 -->
  <div style="text-indent: 50px; height: 4rem; font-size: 0.5rem; padding: 0.5rem; line-height: 1rem; ">
    js彈窗 js彈出DIV,并使整個(gè)頁(yè)面背景變暗</div>
  <!-- 按鈕 -->
  <div style="background: #418BCA; width: 80%; margin: 0 auto; height: 1.5rem; line-height: 1.5rem; text-align: center;color: #fff;margin-top: 1rem; -moz-border-radius: .128rem; -webkit-border-radius: .128rem; border-radius: .128rem;font-size: .59733rem;" onclick="closeWindow()">
    確 定
  </div>
</div>

js代碼:(把jq引進(jìn)來(lái))

1
2
3
4
5
6
7
8
9
10
11
12
13
<script type="text/javascript">
  // 彈窗
  function showWindow() {
    $('#showdiv').show();  //顯示彈窗
    $('#cover').css('display','block'); //顯示遮罩層
    $('#cover').css('height',document.body.clientHeight+'px'); //設(shè)置遮罩層的高度為當(dāng)前頁(yè)面高度
  }
  // 關(guān)閉彈窗
  function closeWindow() {
    $('#showdiv').hide();  //隱藏彈窗
    $('#cover').css('display','none');   //顯示遮罩層
  }
</script>

效果:

總結(jié)

以上所述是小編給大家介紹的JS彈窗 JS彈出DIV并使整個(gè)頁(yè)面背景變暗功能的實(shí)現(xiàn)代碼,希望對(duì)大家有所幫助,如果大家有任何疑問(wèn)歡迎給我留言,小編會(huì)及時(shí)回復(fù)大家的!

    本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶(hù)發(fā)布,不代表本站觀(guān)點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購(gòu)買(mǎi)等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評(píng)論

    發(fā)表

    請(qǐng)遵守用戶(hù) 評(píng)論公約

    類(lèi)似文章 更多