使用Bootstrap Datepicker进行样式周 [英] Style weeks using the Bootstrap Datepicker

查看:179
本文介绍了使用Bootstrap Datepicker进行样式周的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 bootstrap datepicker ,并假设我希望将样式应用于日历打开时出现的日历:

I'm using the bootstrap datepicker and suppose I wish to apply styles to the calendar that appear when the calendar opens:

  1. 突出显示3/1/17 3/7/17红色
  2. 突出显示3/9/17 3/17/17蓝色

如何使用CSS做到这一点? API中是否有允许此功能的功能?

How can I use CSS to do this? Is there a feature in the API that allows for this?

推荐答案

此功能没有直接的API,但是您可以使用选项

There is no direct API for this feature, but you can use option debug: true to inspect component HTML.

定位特定日期的一种方法是使用基于data-day属性值的CSS选择器,例如:[data-day="03/01/2017"].这是一个完整的实时示例:

One way to target a specific day is using a CSS selector based on data-day attribute value, for example: [data-day="03/01/2017"]. Here a full live example:

$('#datetimepicker1').datetimepicker({
  debug: true
});

[data-day="03/01/2017"], [data-day="03/07/2017"]{
  background-color: red;
}

[data-day="03/09/2017"], [data-day="03/17/2017"]{
  background-color: blue;
}

<link href="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.css" rel="stylesheet"/>
<link href="//cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.37/css/bootstrap-datetimepicker.css" rel="stylesheet"/>

<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/moment.js/2.17.1/moment.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.37/js/bootstrap-datetimepicker.min.js"></script>

<div class="input-group date" id="datetimepicker1">
  <input type="text" class="form-control" />
  <span class="input-group-addon">
    <span class="glyphicon glyphicon-calendar"></span>
  </span>
</div>

在这里,您可以找到类似的示例.

Here you can find a similar example.

这篇关于使用Bootstrap Datepicker进行样式周的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆