css - 有没有办法在mat-datepicker中垂直居中datepicker?

标签 css angular-material

有两种状态:

状态 - 01:

enter image description here

状态 - 02:

enter image description here

在 state-01 中,“Choose a date”是垂直居中的。像那样,我试图将“选择日期”文本和所选日期垂直居中。不知道我错过了什么。请帮助我。

我的 stackBlitz 链接是 here

最佳答案

在你的情况下,当你需要使用 box angular-material 设置输入样式时,如果你想使用,请提供输入 'appearance="outline"`,就像这样

<mat-form-field appearance="outline">
    <mat-label>Outline form field</mat-label>
    <input matInput placeholder="Placeholder">
    <mat-icon matSuffix>sentiment_very_satisfied</mat-icon>
    <mat-hint>Hint</mat-hint>
  </mat-form-field>

否则,如果您想像您的示例中那样设置自定义样式,那么您需要一些样式,例如在它具有 float-label 时给它 padding ,如下所示

::ng-deep .mat-form-field.mat-form-field-should-float {
    padding-top:20px;
}

REASON: Normal behavior of mat-input is that it float the label above in some negative values, you can set that float to never so that label doesn't go above, for more you can read in its [OFFICIAL DOC]

( https://material.angular.io/components/input/overview )

关于css - 有没有办法在mat-datepicker中垂直居中datepicker?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59607888/

相关文章:

javascript - 如何使 javascript 窗口位于所有其他窗口之上?

html - 将 2 列布局环绕图像

css - Angular Material - 在 Internet Explorer 和 Safari 浏览器中重叠 div

angularjs - $setPristine 不是函数

javascript - AngularJS/HTML5 嵌套表单验证

css - 如何从 head 标签中删除 Material Angular CSS 代码?

php - chrome 中的类属性困惑

css - 奇怪的宽度 css 问题导致非固定布局

css - 如何修复 @each 指令的 SCSS 编译错误?

Angular - 提供的数据源与数组、可观察对象或数据源不匹配