夜间模式的开启与关闭,父模板的制作

  1. 夜间模式的开启与关闭
    1. 放置点击的按钮或图片。
    2. 定义开关切换函数。
    3. onclick函数调用。
  2. 父模板的制作
    1. 制作网站网页共有元素的父模板html,包括顶部导航,中间区块划分,底部导航,底部说明等。
    2. 汇总相关的样式形成独立的css文件。
    3. 汇总相关的js代码形成独立的js文件。
    4. 形成完整的base.html+css+js
    5. <!DOCTYPE html>
      <html lang="en"xmlns:color="http://www.w3.org/1999/xhtml">
      <head>
          <meta charset="UTF-8">
          <title>Title</title>
          <script>
              function mySwitch() {
                  var myele=document.getElementById("on_off")
                  if(myele.src.match("bulbon"))
                  {
                     myele.src="http://www.runoob.com/images/pic_bulboff.gif"
                      document.getElementById("myBody").style.background="black"
                      document.getElementById("myBody").style.color="white" } 

      else { myele.src="http://www.runoob.com/images/pic_bulbon.gif" document.getElementById("myBody").style.background="white" document.getElementById("mybody").style.color="black" } } </script></head><body id="myBody"><img id="on_off" onclick="mySwitch()" src="http://www.runoob.com/images/pic_bulbon.gif" width="50px"><script> document.write(Date()) </script></body></html>

    6. from flask import Flask,render_template
      
      app = Flask(__name__)
      
      
      @app.route('/')
      def index():
          return render_template('index.html')
      
      @app.route('/zhuce/')
      def zhuce():
          return render_template('zhuce.html')
      
      
      @app.route('/denglu/')
      def denglu():
          return render_template('denglu.html')
      if __name__ == '__main__':
          app.run(debug=True)
      <!DOCTYPE html>
      <html lang="en">
      <head>
          <meta charset="UTF-8">
          <title>登录界面</title>
           <link rel="stylesheet" type="text/css" href="../static/css/vvv.css">
          <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
          <script src="../static/js/ggg.js"></script>
      </head>
      <body id="myBody">
      
      <nav class="navbar navbar-default" role="navigation">
              <div class="container-fluid">
                  <div class="navbar-header">
                      <a class="navbar-brand" href="#">广州商学院</a>
                  </div>
                  <form class="navbar-form navbar-left" role="search">
                      <div class="form-group">
                          <input type="text" class="form-control" placeholder="输入您感兴趣的">
                      </div>
                      <button type="submit" class="btn btn-default">查询</button>
                  </form>
                  <button type="button" class="btn btn-default navbar-btn">导航栏</button>
      
                  <ul class="nav navbar-nav navbar-right"id="myBody">
                      <li ><img id="myOnOff" onclick="mySwitch()" src="http://www.runoob.com/images/pic_bulbon.gif" width="20px">夜间模式</li>
                      <li><a href="#"><span class="glyphicon glyphicon-user"></span> 注册</a></li>
                      <li><a href="登录页面.html"><span class="glyphicon glyphicon-log-in"></span> 登录</a></li>
                      <li><a href="#"><span class=""></span> 退出</a></li>
      
                  </ul>
              </div>
          </nav>
      <div class="div1">
          <div class="div2">登录</div>
          <div class="div3">
             <div class="iconfont ic-user"></div> 用户:<input id="username" type="text" placeholder="请输入用户名">
          </div>
          <div class="div3">
              密码:<input id="userpass" type="text" placeholder="请输入密码">
          </div>
          <div id="error_box"><br></div>
           <div class="div3">
              <button onclick="myLogin()">登陆</button>
          </div>
      </div>
      <br>
      <div id="bottom">
          <a href="">联系我们</a>
          <a href="">加入我们</a>
          <a href="">帮助中心</a>
          <a href="">合作伙伴</a>
      </div>
      
      <div class="copyright">
          <p>Copyright &copy; 2017. Created by <a href="#" target="_blank">ben</a></p>
      </div>
      
      </body>
      </html>

原文地址:https://www.cnblogs.com/0055sun/p/7784451.html