mwl日历标记小时以不同的颜色

时间:2016-08-31 08:05:43

标签: angularjs calendar

我使用mwl日历,我将在另一个颜色inday视图中标记12-13的小时。 有这么简单的可能吗?

mwl calendar

[编辑] 现在我试过这个

<style type="text/css">
    .cal-day-hour-part:nth-of-type(2n) {
        background-color: #f00 !important;
    }
  </style>

用这个掠夺者的例子:

Plunker example

这个工作正常,比我用 .cal-day-hour-part:nth-​​of-type(3n)尝试过的,这不行。有谁知道为什么?

1 个答案:

答案 0 :(得分:0)

DOM的结构如下:

<div class="cal-day-hour">
  <div class="cal-day-hour-part">
  <div class="cal-day-hour-part">
</div>
<div class="cal-day-hour">
  <div class="cal-day-hour-part">
  <div class="cal-day-hour-part">
</div>
...

:nth-of-type(n)选择器匹配特定类型的第n个子元素,其父元素的 。您的DOM中最多有.cal-day-hour-part.cal-day-hour:nth-of-type(n)个孩子。这就是为什么2n可以工作但是3n没有。

关于您的原始问题(并且感谢您要进行澄清的修改),您需要使用.cal-day-hour上的n代替.cal-day-hour:nth-of-type(7) { background-color: #f00 !important; } 并停止使用计数器{{1}}。需要它。

{{1}}

Here's an updated plunkr