css+js实现桌面日历效果代码

代码语言:html

所属分类:布局界面

代码描述:css+js实现桌面日历效果代码

代码标签: 日历 效果

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <style>
@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@400;700&display=swap');

        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
        body {
            display: grid;
            width: 100%;
            min-height: 100vh;
            place-items: center;
            background-size: cover;
            background-position: center center;
            font-family: 'Roboto', sans-serif;
            font-weight: 400;
            padding: 20px;
        }

        #calendar {
            width: 100%;
            max-width: 490px;
            display: -webkit-box;
            display: flex;
            -webkit-box-orient: vertical;
            -webkit-box-direction: normal;
            flex-direction: column;
            background-color: rgba(255,255,255,.9);
            border-radius: 5px;
            padding: 20px;
            gap: 5px;
        }
        #calendar .toprow {
            display: -webkit-box;
            display: flex;
            -webkit-box-orient: horizontal;
            -webkit-box-direction: normal;
            flex-direction: row;
            -webkit-box-pack: justify;
            justify-content: space-between;
            margin-bottom: 20px;
        }
        #calendar .days, #calendar #dates {
            display: grid;
            grid-template-columns: repeat(7, 1fr);
            text-align: center;
            gap: 10px;
        }

        #calendar .days {
            font-weight: 700;
        }

        #calendar #dates div {
            display: grid;
            -webkit-box-align: center;
            align-items: center;
            -webkit-box-pack: center;
            justify-content: center;
            border: 1px solid lightgrey;
            height: 50px;
            border-radius: 5px;;
        }
        #calendar #dates div.date {
            border: 1px solid black;
        }
        #calendar #dates div.today {
            border: 1px solid green;
            background-color: green;
            color: white;
            font-weight: 700;
        }

        button, select, input {
            padding: 5px;
        }
        input {
            width: 70px;
            text-align: center;
        }

        #copy {
            margin-top: 20px;
            padding: 5px;
            position: -webkit-sticky;
            position: sticky;
            background-color: rgba(0,0,0,.5);
            color: white;
            font-size: .8em;
        }
        #copy a {
            color: white;
        }
    </style>

</head>
<body>

    <div id="calendar">
        <div class="toprow">
            <div class="select">
                <select name="year" id="select_month">
                    <option value="0">一月</option>
                    <option value="1">二月</option>
                    <option value="2">三月</option>
                    <option value="3">四月</option>
                    <option value="4">五月</option>
                    <option value="5">六月</option>
                    <option value="6">七月</option>
                    <option value="7">八月</option>
                    <option value="8">九月</option>
                    <option value="9">十月</option>
                    <option value="10">十一月</option>
                    <option value="11">十二月</option>
                </select>
                <input type="number" value="2020" id="select_year">
            </div>
            <div class="navigate">
                <button id="prev_month">上个月</button>
                <button id="curr_month">当前</button>
                <button id="next_month">下个月</button>
            </div>
        </div>
        <div class="days">
            <div>
                日
            </div>
            <div>
                一
            </div>
            <div>
                二
            </div>
            <div>
                三
  .........完整代码请登录后点击上方下载按钮下载查看

网友评论0