- 夜间模式的开启与关闭
- 放置点击的按钮或图片。
- 定义开关切换函数。
- onclick函数调用。
- 父模板的制作
- 制作网站网页共有元素的父模板html,包括顶部导航,中间区块划分,底部导航,底部说明等。
- 汇总相关的样式形成独立的css文件。
- 汇总相关的js代码形成独立的js文件。
- 形成完整的base.html+css+js
1 <!DOCTYPE html> 2 <html lang="en"> 3 <head> 4 <meta charset="UTF-8"> 5 <title>夜间模式</title> 6 <script> 7 function mySwitch(){ 8 var oBody = document.getElementById("myBody"); 9 var oOnoff = document.getElementById("myOnOff") 10 if(oOnoff.src.match("bulbon")){ 11 oOnoff.src="http://www.runoob.com/images/pic_bulboff.gif"; 12 oBody.style.background="black"; 13 oBody.style.color="white"; 14 }else{ 15 oOnoff.src="http://www.runoob.com/images/pic_bulbon.gif"; 16 oBody.style.background="white"; 17 oBody.style.color="black"; 18 } 19 } 20 </script> 21 </head> 22 <body id="myBody"> 23 <img id="myOnOff" onclick="mySwitch()" src="http://www.runoob.com/images/pic_bulbon.gif" width="40px"> 24 <script> 25 document.write(Date()) 26 </script> 27 28 </body> 29 </html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>首页</title>
<script src="../static/js/base.js"></script>
<link type="text/css" rel="stylesheet" href="../static/css/styles.css">
</head>
<body>
<nav>
<img id="myOnOff" οnclick="mySwitch()"
src="https://tva4.sinaimg.cn/crop.0.0.1242.1242.180/bde8475djw8f1hu7mrcy2j20yi0yiabl.jpg" width="30px">
<a href="http://localhost:63342/guanli/templates/base.html?_ijt=q62n14skoqnec43tobo0psd0i3">首页</a>
<a href="http://localhost:63342/guanli/templates/zhuce.html?_ijt=cipfjfad2e7o54e0s796j1pe0c">注册</a>
<a href="http://localhost:63342/guanli/templates/denglu.html?_ijt=9gs2lnbhs2sh1no40cv5e982b9">登录</a>
</nav>
<div class="area">
</div>
<div class="img">
<div>
<a href="base.html"><img src="http://www.zcool.com.cn/community/037471d55de8fc900000171405bc2ee.jpg" height="160px" width="240px"></a>
</div>
</div>
</body>
</html>