Expansion-panel from material angular 4

家住魔仙堡 提交于 2019-12-03 12:31:40

In your style.css or your components style you need to add the following css:

/deep/ .parametersPanel .mat-expansion-panel-body {
    padding: 0;
}

This is due to view encapsulation. You can read more about this here: https://angular.io/guide/component-styles

Update:

The use of /deep/, ::ng-deep to modify the styles of material components has been deprecated. See this link.

However, using @angular/core ^6.1.0 and @angular/material ^6.4.6 I was able to change the style of Angular Material's Expansion panel without having to add anything specific. It seems like you can now simply change the style in your components css file. So this should work:

.mat-expansion-panel-body {
    padding: 0;
}

You can read here for more information about the deprecation of /deep/, ::ng-deep here.

Instead of /deep/ you should use ::ng-deep, which is an alias provided by angular. Support for /deep/ etc. is already removed from chrome browser. So in your example that would be:

::ng-deep .parametersPanel .mat-expansion-panel-body {
    padding: 0;
}
George C.

This works 100%.

Add this inside your style.css:

.mat-expansion-panel-content > .mat-expansion-panel-body {
  padding: 0 !important;
}

this one worked for me

::ng-deep .mat-expansion-panel-body {
 padding: 0px 0px 0px 0px; 

}

I hope that will work for you

You can easily remove parent padding.

<div class="removePadding">
   <mat-list-item *ngFor="let item of item.children" class="testingSmall">
      <h3 matLine>{{item.label}}</h3>
   </mat-list-item>
</div>

.removePadding{
   margin: 0 -24px -16px;
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!