码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2017-11-02 22:02:46      阅读:307      评论:0      收藏:0      [点我收藏+]

标签:query   foo   document   body   模板   yellow   function   back   bis   

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>夜间模式</title>
    <script>
        function mySwitch() {
            var oBody = document.getElementById("mybody");
            var oOnoff = document.getElementById("myonoff");
            if (oOnoff.src.match("bulbon")) {
                oOnoff.src = "http://www.runoob.com/images/pic_bulboff.gif";
                oBody.style.background = "black";
                oBody.style.color = "yellow"
            } else {
                oOnoff.src = "http://www.runoob.com/images/pic_bulbon.gif";
                oBody.style.background = "white";
                oBody.style.color = "black"
            }
        }


    </script>
</head>
<body id="mybody">
<img id="myonoff" onclick="mySwitch()" src="http://www.runoob.com/images/pic_bulbon.gif" width="40px">
<script>
    document.write(Date())
</script>
</body>
</html>

2.

css

img {
    width: 400px; 
}

div.sa {
    border-style: solid; 
    border-width: 5px; 
    border-color: red; 
    width: 400px; 
    float: left; 
    margin: 5px; 
}

div.sa img {
    width: 100%;
    heigh: aute; 
}

div.st {
    text-align: center;
    padding: 2px; 
}

div.sa:hover {
    border-style: solid;
    border-width: 5px;
    border-color: green;
} 

js

function mySwitch() {
    var oBody = document.getElementById("mybody");
    var oOnoff = document.getElementById("myonoff");
    if (oOnoff.src.match("bulbon")) {
        oOnoff.src = "http://www.runoob.com/images/pic_bulboff.gif";
        oBody.style.background = "black";
        oBody.style.color = "yellow"
    } else {
        oOnoff.src = "http://www.runoob.com/images/pic_bulbon.gif";
        oBody.style.background = "white";
        oBody.style.color = "black"
    }
}

 html文件:

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>Bootstrap 实例 - 倒置的导航栏</title>
    <link rel="stylesheet" type="text/css" href="../static/css/lin.css">
    <link rel="stylesheet" href="http://cdn.static.runoob.com/libs/bootstrap/3.3.7/css/bootstrap.min.css">
    <script src="http://cdn.static.runoob.com/libs/jquery/2.1.1/jquery.min.js"></script>
    <script src="http://cdn.static.runoob.com/libs/bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <script src="../static/js/daohang.js"></script>
</head>
<body id="mybody">

<nav class="navbar navbar-inverse" role="navigation">
    <div class="container-fluid">
        <div class="navbar-header">
            <a class="navbar-brand" href="#">首页</a>
        </div>
        <div>
            <ul class="nav navbar-nav">
                <li><a href="#" onclick="">登陆</a></li>
                <li><a href="#" onclick="">注册</a></li>
                <li class="dropdown">
                    <a href="#" class="dropdown-toggle" data-toggle="dropdown">
                        设置 <b class="caret"></b>
                    </a>
                    <ul class="dropdown-menu">
                        <li><a href="#">收藏</a></li>
                        <li><a href="#">分享</a></li>
                        <li><a href="#">搜索</a></li>
                        <li class="divider"></li>
                        <li><a href="#">点赞</a></li>
                    </ul>
                </li>
                <li><a href="#">||</a></li>
            </ul>
        </div>
        <div style="float: left">
            <img id="myonoff" onclick="mySwitch()" src="http://www.runoob.com/images/pic_bulbon.gif" style="width:40px" >
        </div>
        <div>
            <input type="text" name="user" id="user" placeholder="请输入内容">
            <input type="button" value="搜索" class="btn btn-success" onclick="">
        </div>
    </div>
</nav>

<nav class="navbar navbar-inverse navbar-fixed-bottom" role="navigation">
    <ul class="nav navbar-nav">
        <li><img src="http://www.gzcc.cn/2016/images/footer1-logo.png"></li>
        <li style="color: bisque;">版权所有@jk</li>
    </ul>
</nav>

<script>
    document.write(Date())
</script>
<div>
    <div class="sa">
        <a href="http://desk.zol.com.cn/"><img
                src="http://pic7.photophoto.cn/20080529/0034034465128235_b.jpg"></a>
        <div class="st"><a href="http://desk.zol.com.cn/">tu1</a></div>
    </div>
    <div class="sa">
        <a href="http://desk.zol.com.cn/"><img
                src="https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1509638428671&di=7266e0025649123b4c4cde79925c26b3&imgtype=0&src=http%3A%2F%2Fpic38.nipic.com%2F20140228%2F3822951_135521683000_2.jpg"></a>
        <div class="st"><a href="http://desk.zol.com.cn/">tu2</a></div>
    </div>
   
</div>
</body>
</html>

 

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

标签:query   foo   document   body   模板   yellow   function   back   bis   

原文地址:http://www.cnblogs.com/lzp963/p/7774554.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!