simple-calendar实现一个日历效果代码

代码语言:html

所属分类:选择器

代码描述:simple-calendar实现一个日历效果代码

代码标签: 日历

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

<!DOCTYPE html>
<html>

<head>
    <meta charset='utf-8'>
    <meta http-equiv="X-UA-Compatible" content="chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link href='https://fonts.googleapis.com/css?family=Architects+Daughter' rel='stylesheet' type='text/css'>

    <link type="text/css" rel="stylesheet" href="//repo.bfw.wiki/bfwrepo/css/simple-calendar.css">


    <style>
        #calendar{
            width: 100%
          }
          .clearfix{
            margin-bottom: 50px !important;
          }
          
    </style>
</head>

<body>
    <header>
        <div class="inner">
            <h1>Simple-calendar</h1>
            <h2>一个简单的日历插件</h2>
        </div>
    </header>

    <div id="content-wrapper">
        <div class="inner clearfix">
            <div id='calendar'>

            </div>
        </div>

        <div class="inner clearfix">
            <section id="main-content">
                <h1>
                    <a id="simple-calendar开发文档" class="anchor" href="#simple-calendar%E5%BC%80%E5%8F%91%E6%96%87%E6%A1%A3" aria-hidden="true"><span aria-hidden="true" class="octicon octicon-link"></span></a>Simple-Calendar开发文档</h1>

                <hr>


                <a id="引入资源" class="anchor" href="#%E5%BC%95%E5%85%A5%E8%B5%84%E6%BA%90" aria-hidden="true"><span aria-hidden="true" class="octicon octicon-link"></span></a>引入资源</h2>

                <p>使用日历插件前首先要引用资源:JS CSS</p>

                <div class="highlight highlight-source-js">
                    <pre><span class="pl-k">&lt;</span>link rel<span class="pl-k">=</span><span class="pl-s"><span class="pl-pds">"</span>stylesheet<span class="pl-pds">"</span></span> type<span class="pl-k">=</span><span class="pl-s"><span class="pl-pds">"</span>text/css<span class="pl-pds">"</span></span> href<span class="pl-k">=</span><span class="pl-s"><span class="pl-pds">"</span>css/simple-calendar.css<span class="pl-pds">"</span></span><span class="pl-k">&gt;</span>

<span class="pl-k">&lt;</span>script type<span class="pl-k">=</span><span class="pl-s"><span class="pl-pds">"</span>text/javascript<span class="pl-pds">"</span></span> src<span class="pl-k">=</span><span class="pl-s"><span class="pl-pds">"</span>js/simple-calendar.js<span class="pl-pds">"</span></span><span class="pl-k">&gt;&lt;</span><span class="pl-k">/</span>script<span class="pl-k">&gt;</span></pre>
                </div>

                <h2>
                    <a id="初始化一个日历" class="anchor" href="#%E5%88%9D%E5%A7%8B%E5%8C%96%E4%B8%80%E4%B8%AA%E6%97%A5%E5%8E%86" aria-hidden="true"><span aria-hidden="true" class="octicon octicon-link"></span></a>初始化一个日历</h2>

                <p>首先为calendar准备一个容器,可以设置大小,也可以在options中设置,不设置的话自动设为默认</p>

                <div class="highlight highlight-text-html-basic">
                    <pre>  &lt;<span class="pl-ent">div</span> <span class="pl-e">id</span>=<span class="pl-s"><span class="pl-pds">'</span>container<span class="pl-pds">'</span></span>&gt;&lt;/<span class="pl-ent">div</span>&gt;</pre>
                </div>

                <div class="highlight highlight-text-html-basic">
                    <pre><span class="pl-s1">  &lt;<span class="pl-ent">script</span>&gt;</span>
<span class="pl-s1">    <span class="pl-k">var</span> myCalendar <span class="pl-k">=</span> <span class="pl-k">new</span> <span class="pl-en">SimpleCalendar</span>(<span class="pl-s"><span class="pl-pds">'</span>#container<span class="pl-pds">'</span></span>);</span>
<span class="pl-s1">  &lt;/<span class="pl-ent">script</span>&gt;</span></pre>
                </div>

                <p>这样一个日历就诞生了 ^-^</p>

                <h2>
                    <a id="配置项说明" class="anchor" href="#%E9%85%8D%E7%BD%AE%E9%A1%B9%E8%AF%B4%E6%98%8E" aria-hidden="true"><span aria-hidden="true" class="octicon octicon-link"></span></a>配置项说明</h2>

                <div class="highlight highlight-source-js">
                    <pre><span class="pl-k">var</span> options <span class="pl-k">=</span> {
      width<span class="pl-k">:</span> <span class="pl-s"><span class="pl-pds">'</span>500px<span class="pl-pds">'</span></span>,
      height<span class="pl-k">:</span> <span class="pl-s"><span class="pl-pds">'</span>500px<span class="pl-pds">'</span></span>,
      language<span class="pl-k">:</span> <span class="pl-s"><span class="pl-pds">'</span>CH<span class="pl-pds">'</span></span>, <span class="pl-c">//语言</span>
      showLunarCalendar<span class="pl-k">:</span> <span class="pl-c1">true</span>, <span class="pl-c">//阴历</span>
      showHoliday<span class="pl-k">:</span> <span class="pl-c1">true</span>, <span class="pl-c">//休假</span>
      showFestival<span class="pl-k">:</span> <span class="pl-c1">true</span>, <span class="pl-c">//节日</span>
      showLunarFestival<span class="pl-k">:</span> <span class="pl-c1">true</span>, <span class="pl-c">//农历节日</span>
      showSolarTerm<span class="pl-k">:</span> <span class="pl-c1">true</span>, <span class="pl-c">//节气</span>
      showMark<span class="pl-k">:</span> <span class="pl-c1">true</span>, <span class="pl-c">//标记</span>
      timeRange<span class="pl-k">:</span> {
        startYear<span class="pl-k">:</span> <span class="pl-c1">1900</span>,
        endYear<span class="pl-k">:</span> <span class="pl-c1">2049</span>
      },
      mark<span class="pl-k">:</span> {
        <span class="pl-s"><span class="pl-pds">'</span>2016-5-5<span class="pl-pds">'</span></span><span class="pl-k">:</span> <span class="pl-s"><span class="pl-pds">'</span>上学<span class="pl-pds">'</span></span>
      },
      theme<span class="pl-k">:</span> {
        changeAble<span class="pl-k">:</span> <span class="pl-c1">false</span>,
        weeks<span class="pl-k">:</span> {
          backgroundColor<span class="pl-k">:</span> <span class="pl-s"><span class="pl-pds">'</span>#FBEC9C<span class="pl-pds">'</span></span>,
          fontColor<span class="pl-k">:</span> <span class="pl-s"><span class="pl-pds">'</span>#4A4A4A<span class="pl-pds">'</span></span>,
          fontSize<span class="pl-k">:</span> <span class="pl-s"><span class="pl-pds">'</span>20px<span class="pl-pds">'</span></span>,
        },
        days<span class="pl-k">:</span> {
          backgroundColor<span class="pl-k">:</span> <span class="pl-s"><span class="pl-pds">'</span>#ffffff<span class="pl-pds">'</span></span>,
          fontColor<span class="pl-k">:</span> <span class="pl-s"><span class="pl-pds">'</span>#565555<span class="pl-pds">'</span></span>,
          fontSize<span class="pl-k">:</span> <span class="pl-s"><span class="pl-pds">'</span>24px<span class="pl-pds">'</span></span>
        },
        todaycolor<span class="pl-k">:</span> <span class="pl-s"><span class="pl-pds">'</span>orange<span class="pl-pds">'</span></span>,
        activeSelectColor<span class="pl-k">:</span> <span class="pl-s"><span class="pl-pds">'</span>orange<span class="pl-pds">'</span></span>,
      }
    }</pre>
                </div>

                <h3>
                    <a id="国际化" class="anchor" href="#%E5%9B%BD%E9%99%85%E5%8C%96" aria-hidden="true"><span aria-hidden="true" class="octicon octicon-link"></span></a>国际化</h3>

                <blockquote>
                    <p>language: 语言的话目前只支持中文和英文,分别对应'CH','EN'
                    </p>
                </blockquote>

                <p>如果想要加更多的语言或者更改现在的显示,可以直接更改languageData内容</p>

                <h3>
                    <a id="节日显示配置" class="anchor" href="#%E8%8A%82%E6%97%A5%E6%98%BE%E7%A4%BA%E9%85%8D%E7%BD%AE" aria-hidden="true"><span aria-hidden="true" class="octicon octicon-link"></span></a>节日显示配置</h3>

                <div class="highlight highlight-source-js">
                    <pre>showLunarCalendar<span class="pl-k">:</span> <span class="pl-c1">true</span>, <span class="pl-c">//是否显示阴历日期</span>
showHoliday<span class="pl-k">:</span> <span class="pl-c1">true</span>,       <span class="pl-c">//是否显示休假休假</span>
showFestival<span class="pl-k">:</span> <span class="pl-c1">true</span>,      <span class="pl-c">//是否显示国际节日</span>
showLunarFestival&.........完整代码请登录后点击上方下载按钮下载查看

网友评论0