App下載

簡單前端彈窗小案例分享!

猿友 2021-07-29 14:11:05 瀏覽數(shù) (2623)
反饋

在程序運行中的報錯我們都會收到相關錯誤彈窗的警告,那么今天小編就和大家分享個“簡單前端彈窗小案例分享! ”相關內(nèi)容分享!

我們通過運用 html 及原生 js 寫個彈窗,供參考。

<!DOCTYPE html>
<html>
 <head>
  <meta charset="utf-8" />
  <title></title>
  <style type="text/css">
   body{
    margin: 0px;
   }
   .zhezhao{
    position: fixed;
    left: 0px;
    top: 0px;
    background: #000;
    width: 100%;
    height: 100%;
    opacity: 0.5;
   }
   .tankuang{
    position: relative;
    background: #fff;
    width: 50%;
    height: 80%;
    border-radius: 5px;
    margin: 5% auto;
   }
   #header{
    height: 40px;
   }
   #header-right{
    position: absolute;
    width: 25px;
    height: 25px;
    border-radius: 5px;
    background: red;
    color: #fff;
    right: 5px;
    top: 5px;
    text-align: center;
   }
  </style>
 </head>
 <body>
  <button type="button" onclick="dianwo()">點我</button>
  <div class="zhezhao" id='zhezhao'>
   <div class="tankuang">
    <div id="header">
     <span>我是彈窗</span>
     <div id="header-right" onclick="hidder()">x</div>
    </div>
   </div>
  </div>
  <script type="text/javascript">
   document.getElementById('zhezhao').style.display="none";
   function dianwo(){
    document.getElementById('zhezhao').style.display="";
   }
   function hidder(){
    document.getElementById('zhezhao').style.display="none";
   }
  </script>
 </body>
</html>

以上就是小編自己編寫的有關于“簡單前端彈窗小案例分享! ”這方面的相關內(nèi)容分享,當然了實現(xiàn)的方法肯定不只有一種,有感興趣的小伙伴們可以在W3Cschool中進行全面的學習! 


0 人點贊