1. 程式人生 > >11.2

11.2

es2017 rri mat 獨立 www. nav har ima 技術

  1. 夜間模式的開啟與關閉
    1. 放置點擊的按鈕或圖片。
    2. 定義開關切換函數。
    3. onclick函數調用。
  2. 父模板的制作
    1. 制作網站網頁共有元素的父模板html,包括頂部導航,中間區塊劃分,底部導航,底部說明等。
    2. 匯總相關的樣式形成獨立的css文件。
    3. 匯總相關的js代碼形成獨立的js文件。
    4. 形成完整的base.html+css+js
      <!DOCTYPE html>
      <html lang="en">
      <head>
          <meta charset="UTF-8">
          <title>登錄</title>
          <link rel
      ="stylesheet" type="text/css" href="../static/dl.css"> <script src="../static/js/denlu.js"></script> </head> <nav style="background-color: blanchedalmond"> <img src="https://haitao.nos.netease.com/e740ea878fa94730b3d86579a8e68a26.jpg" width="600px"> <input type
      ="text" placeholder="輸入你想找的寶貝"> <input type="button" value="搜索"> <a>購物車</a> <a href="https://www.kaola.com/?navindex=1&zn=top">首頁</a> <a href="https://www.kaola.com/activity/flashSaleIndex/show.html?navindex=2&zn=top">今日限時購</a> <a href
      ="https://www.kaola.com/activity/newArrival.html?navindex=3&zn=top">每日上新</a> <img id="myOnOff" onclick="mySwitch()" src="../static/image/on.png" width="40px"> </nav> <body id="myBody"> <div class="box"> <div id="tittle"><h2 align="center">登錄</h2></div> <div class="input_box"> 賬戶: <input id="uname" type="text" placeholder="請輸入用戶名"> </div> <div class="input_box"> 密碼: <input id="upass" type="password" placeholder="請輸入密碼"> </div> <div id="error_box"><br></div> <div class="input_box"> <button onclick="foLogin()">登錄</button> </div> <button type="button" onclick="foLogin()"><a href="zhuce.html">註冊</a></button> </div> </body> </html>
      box{
           width: 300px;
      }
      
      div.box {
          border: 1px solid #000000;
          height: 290px;
          width: 300px;
          float: left;
          margin: 50px;
          background: antiquewhite;
      }
      
      div.input_box{
          text-align: center;
          height: 50px;
          width: auto;
          padding: 5px
      }
      
      div.input_box button{
          border: aqua;
          font-size: 20px;
          width: 100px;
          height: 30px;
          background: coral;
      }
      function mySwitch() {
                  var oBady=document.getElementById("myBody");
                  var oOnoff=document.getElementById("myOnOff");
                  if(oOnoff.src.match("on")){
                      oOnoff.src="../static/image/off.png";
                      oBady.style.background="gray";
                      oBady.style.color="white";
                  }else {
                      oOnoff.src = "../static/image/on.png";
                      oBady.style.background = "white";
                      oBady.style.color = "black" ;
                  }
              }

      技術分享

      技術分享

11.2