【问题标题】:set color in ng-datepicker在 ng-datepicker 中设置颜色
【发布时间】:2018-10-29 14:27:02
【问题描述】:

我想设置活动日期的背景颜色。默认值为蓝色,我想将其设置为绿色。知道如何实现吗?

我使用下面的日期选择器:

Library

这是我的代码:

html:

 <ng-datepicker [options]=option [(ngModel)]="date"></ng-datepicker>

ts:

 this.option = {
  minYear: 1970,
  maxYear: 2050,
  displayFormat: 'MM.DD.YYYY',
  barTitleFormat: 'MMMM YYYY',
  dayNamesFormat: 'dd',
  firstCalendarDay: 1, // 0 - Sunday, 1 - Monday
  locale: deLocale,
  //minDate: new Date(Date.now()), // Minimal selectable date
  //maxDate: new Date(Date.now()),  // Maximal selectable date
  barTitleIfEmpty: 'Wähle ein Datum aus',
  placeholder: 'Wähle ein Datum aus', // HTML input placeholder attribute (default: '')
  addStyle: {
  }, // Optional, value to pass to [ngStyle] on the input field
  fieldId: 'my-date-picker', // ID to assign to the input field. Defaults to datepicker-<counter>
  useEmptyBarTitle: false, // Defaults to true. If set to false then barTitleIfEmpty will be disregarded and a date will always be shown 
};

【问题讨论】:

  • 在问题中添加相关代码sn-p。这太笼统和不清楚了。我的意思是我们看不到你的代码,没有它我们怎么知道哪里出了问题?

标签: css angular datepicker


【解决方案1】:

将以下内容添加到组件的 CSS 中会使当天的背景变为绿色

span.day-unit.is-today.is-selected {
    background-color: green !important;
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-03-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-02-12
    • 1970-01-01
    • 1970-01-01
    • 2021-05-28
    相关资源
    最近更新 更多