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

<!DOCTYPE html>
<html lang="en"> <head> <meta charset="UTF-8"> <title>img</title> <link rel="stylesheet" type="text/css" href="../static/css/i.css"> </head> <body> <input type="text"> <button>查找</button> <div class="recommend"> <div class="img"> <a href="http://www.gzcc.cn"><img src="http://img.zcool.cn/community/013bea58db839da801219c777e2827.gif"></a> <div class="desc"><a href="http://www.gzcc.cn">校园风光</a></div> </div> <div class="img"> <a href="http://www.gzcc.cn"><img src="http://img.zcool.cn/community/013e3a58db839da801219c7714f34c.gif"></a> <div class="desc"><a href="http://www.gzcc.cn">校友风采</a></div> </div> <div class="img"> <a href="http://www.gzcc.cn"><img src="http://img.zcool.cn/community/0102fd58db839ea801219c774b8624.gif"></a> <div class="desc"><a href="http://www.gzcc.cn">学校文化</a></div> </div> <div class="img"> <a href="http://www.gzcc.cn"><img src="http://img.zcool.cn/community/01701158db839ea801219c77232e16.gif"></a> <div class="desc"><a href="http://www.gzcc.cn">学生风采</a></div> </div> </div> <div class="clearfloat"> <img src="http://img.zcool.cn/community/01ec0058db83a8a801219c77daff8a.gif" > </div> </body> </html>

 

夜间模式
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>夜晚模式</title> <script> function mySwich() { var oBody = document.getElementById("myBody"); var oOnoff = document.getElementById("myOnoff"); if (oOnoff.src.match("1509")){ oOnoff.src="https://timgsa.baidu.com/timg?image&quality=80&size=b10000_10000&sec=150"; oBody.style.background="black"; oBody.style.color="green"; }else { oOnoff.src="https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1509"; oBody.style.background="white"; oBody.style.color="pink"; } } </script> </head> <body id="myBody"> <img id="myOnoff" onclick="mySwich()" src="https://timgsa.baidu.com/timg?image&quality=80&size=b10000_10000&sec=150" width="60px"> <script> document.write(Date()) </script> </body> </html>

  

复制代码
img {
    width: 300px;
}

div .img {
    border: 1px solid #ccc;
    width: 150px;
    float: left;
    margin: 5px;

}
div.img img {
    width: 100%;
    height: auto;
}


div.desc {
    text-align: center;
    padding: 5px;

}

div.img:hover {
    border: 1px solid #000000;
}

div.clearfloat {
    clear: both;
}
posted @ 2017-11-02 21:47  031庄园  阅读(174)  评论(0编辑  收藏  举报