创建日历

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>日历</title>
    <style>
        *{
            margin: 0;
            padding: 0;         
        }
    .box{
        width: 150px;
        height:180px;
        background-color: skyblue;
        margin: 100px auto;
        text-align: center;
    }
    #top{
        font-size:14px;
        color: #fff;
        line-height: 60px;
    }
    #bottom{
        width: 75px;
        height: 75px;
        background-color: pink;
        color: #fff;
        line-height: 75px;
        margin: 0 auto;
        font-size: 50px;
        border-radius: 5px;
    }
    </style>
</head>
<body>

<div class="box">
    <div id="top"></div>
    <div id="bottom"></div>
</div>



<script>
    window.onload=function(){
        var top = document.getElementById("top");

        var bottom = document.getElementById("bottom");

        var date = new Date();

        var arr= ["星期日","星期一","星期二","星期三","星期四","星期五","星期六"];

        top.innerHTML = date.getFullYear()+"-"+(date.getMonth()+1)+"-"+date.getDate()+" "+arr[date.getDay()];

        bottom.innerHTML = date.getDate();

    }








</script>





</body>
</html>
阅读更多
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/yingleiming/article/details/80072371
个人分类: javascript
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭
关闭