html - 如何覆盖 angular2 中 md-input-container 的样式?

标签 html css angular angular-material2

我有以下使用 Angular Material 设计的 md-input-container 代码:

<md-input-container>
      <input mdInput [placeholder]="'common.password' | translate" type="password" formControlName="password" (change)="onPasswordChange($event.target.value)" required validate-onBlur/>
      <md-hint *ngIf="frmLoginInfo.controls.password.pristine" class="s-text-caption s-hint">{{ 'signup.pwdRule' | translate }}</md-hint>
</md-input-container>

此容器内部有一个带有类 (mat-input-wrapper) 的 div,它的内边距为 padding-bottom: 1.296875em。

如何覆盖容器的这种填充样式?

PS:将类添加到容器并将 padding: 0px 作为 important 也不起作用。

enter image description here

最佳答案

更新

Angular 关于 /deep/>>> 的官方回应 ( Thanks @DeborahK )

Support for the emulated /deep/ CSS Selector (the Shadow-Piercing descendant combinator aka >>>) has been deprecated to match browser implementations and Chrome’s intent to remove. ::ng-deep has been added to provide a temporary workaround for developers currently using this feature.

发件人:http://angularjs.blogspot.co.uk/2017/07/angular-43-now-available.html

Another related question


为组件添加更具体的样式 - see CSS specificity

html

<md-input-container id="forceStyle">
    <input mdInput [placeholder]="'common.password' | translate" type="password" formControlName="password" (change)="onPasswordChange($event.target.value)" required validate-onBlur/>
    <md-hint *ngIf="frmLoginInfo.controls.password.pristine" class="s-text-caption s-hint">{{ 'signup.pwdRule' | translate }}</md-hint>
</md-input-container>

CSS

>>> #forceStyle .mat-input-wrapper {
  padding-bottom: 0px;
}

您需要 >>> 说明 here

然而,/deep/>>> 已弃用,如 here 所述

enter image description here

Live plunker example

关于html - 如何覆盖 angular2 中 md-input-container 的样式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45274656/

相关文章:

javascript - 使用新的 CSS 文件覆盖当前网站的

html - div 之间的间距

html - 菜单大小取决于屏幕分辨率

css - 定位文本以在 Firefox 和 Chrome 上显示相同

node.js - 带有 GRPC 的 Angular Universal

java - 如何检查单选按钮是否在 Selenium WebDriver 中被选中?

javascript - 有序列表上的动画

css - 避免边框重叠 CSS

angular - 我们可以使用 HTTP 2 服务器推送存在于其他 CDN 中的 Assets 吗?

angular - 在特定 route 添加类 - Angular 2