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

  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</title>
          <link rel="stylesheet" href="../static/css/base.css" type="text/css">
          <script src="../static/js/base.js"></script>
           <base target="_blank" />
      </head>
      <body id="myBody">
      
      <nav class="nav">
          <ul>
              <li><a href="{{ url_for('index') }}"><img  src="../static/images/daohang1.jpg">首页</a></li>
              <li><a href=""><img  src="../static/images/daohang2.jpg">下载</a></li>
              <li><a href=""><img src="../static/images/daohang3.jpg">新闻</a></li>
              <li><a href=""><img src="../static/images/daohang5.jpg">短消息</a></li>
              <li><a href="{{ url_for('sign_in') }}"><img src="../static/images/daohang4.jpg">登录</a></li>
              <li><a href="{{ url_for('sign_up') }}"><img src="../static/images/daohang4.jpg">注册</a></li>
              <img id="on_off" onclick="mySwitch()" src="../static/images/bulbon.jpg" width="50px">
              <button style="float: right;margin: 5px auto;border-radius: 5px;height: 30px" type="submit">搜索</button>
              <input style="float: right;margin: 5px auto;border-radius: 8px;width: 200px;height: 20px;"  type="text" name="search"PLACEHOLDER="输入要搜索的内容">
      
          </ul>
      </nav>
      
      <div id="bottom">
          <a href="">联系我们</a>
          <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">niu</a></p>
      </div>
      
      </body>
      </html>
      .nav ul{
                  width: 1300px;
                  border: 1px solid pink;
                  margin: 50px auto 0px auto;
              }
              .nav ul li{
                  float: left;
              }
              .nav ul li a{
      
                  width: 80px;
                  height: 28px;
                  line-height: 28px;
                  background-color: pink;
                  color: aliceblue;
                  margin: 5px 35px;
                  font-size: 12px;
                  display: block;
                  text-align: center;
                  text-decoration: none;
              }
              .nav ul li a:hover{
                  width: 78px;
                  height: 26px;
                  line-height: 28px;
                  border: 1px solid pink;
                  background: #FFF;
              }
              #on_off{
                  float: right;
                  margin: 5px;
              }
              .nav img{
                  height: 28px;
                  width:28px;
                  float: left
              }
              #bottom{
           position:fixed;
                  bottom:50px;
                  left:600px;
      }
              #bottom a{
                  font-size: 12px;
                  color: #828078;
                  text-decoration: none;
              }
      .copyright {
                  position:fixed;
                  bottom:0;
                  left:650px;
      }
      
      .copyright p, .copyright a {
        color: #828078;
        font-size: 12px;
        text-decoration: none;
        transition: color 0.3s ease-out;
      }
      .copyright p a:hover, .copyright a a:hover {
        color: #f2672e;
      }
      function mySwitch()
      {
          var myele=document.getElementById("on_off")
          if (myele.src.match("bulbon"))
          {
              myele.src="../static/images/bulboff.jpg"
              document.getElementById("myBody").style.background="grey"
              document.getElementById("demo").style.color="white"
          }
          else
          {
              myele.src="../static/images/bulbon.jpg"
              document.getElementById("myBody").style.background="white"
              document.getElementById("demo").style.color="grey"
          }
      }

       

posted @ 2017-11-03 18:02  078刘凯敏  阅读(183)  评论(0编辑  收藏  举报