angular - 为 Angular 6 自定义 Angular Material Datepicker 大小
问题描述
我想在 Angular 6 中重置 Angular Material datepicker 的宽度和高度。
我已经检查了 chrome 中 datepicker 元素的类,并使用如下
.mat-datepicker-content .mat-calendar{
width: unset !important;
height: unset !important;
}
当我在 chrome 中更改属性时,它会反映在 UI 中,但是当我在代码中添加它时,它不会应用于 DatePicker。
我在 Angular Material Model 组件中使用了 Datepicker。
请帮忙。
解决方案
有两种方法可以应用这个 css
- 在主 style.scss 或 style.css 中添加相同的样式
或者
- 在您的样式代码前添加 ::ng-deep :
::ng-deep.mat-datepicker-content .mat-calendar{
width: unset !important;
height: unset !important;
}
推荐阅读
- c# - 如何使用 c# 的 SqlCommand 获取 IDENT_CURRENT 结果?
- html - 如何使用父标签中的样式强制所有标签?
- c++11 - 将 RepeatedPtrField 分配给 protobuf 消息中的重复字段
- vbscript - 如何在不显示错误的情况下运行脚本
- kubernetes - Kubernetes HPA 在缩减期间杀死随机 pod | 无论如何,为了避免杀死一个随机的 pod,而不是去使用低利用率的 pod
- php - 这是我在 laravel 数据库中插入多条记录的代码。那么,它不起作用吗?有人帮我吗?
- linux - 如何从文件名中删除日期linux
- mongodb - 如何在 Mongo DB 中合并文档数组
- jquery - 元属性 og:图像在 whatsapp 中不起作用
- javascript - React 和 PropTypes