最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Increasing the Width of the MatBottomSheet? - Stack Overflow

programmeradmin0浏览0评论

The following CSS increases the height but not the width:

.mat-bottom-sheet-container {
  min-height: 100vh;
  min-width: 100vw;
  margin-top: 80px;
}

Anyone know how to increase the MatBottomSheet width? Stackblitz new window demo.

Note that the demo has to run in a new window (Open in New Window) in order to see that the MatBottomSheet is not full view.

The following CSS increases the height but not the width:

.mat-bottom-sheet-container {
  min-height: 100vh;
  min-width: 100vw;
  margin-top: 80px;
}

Anyone know how to increase the MatBottomSheet width? Stackblitz new window demo.

Note that the demo has to run in a new window (Open in New Window) in order to see that the MatBottomSheet is not full view.

Share Improve this question asked Oct 4, 2019 at 5:12 OleOle 47.5k70 gold badges238 silver badges445 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 3

this is because you have mat-bottom-sheet-container-large applied to the same element which is having css

.mat-bottom-sheet-container-large {
     min-width: 512px;
     max-width: calc(100vw - 256px); 
}

remove this class or add !important property to min-width in your mat-bottom-sheet-container class

.mat-bottom-sheet-container {
  min-height: 100vh;
  min-width: 100vw !important;
  margin-top: 80px;
}

Better instead of CSS overwriting .mat-bottom-sheet-container, you can use your own custom CSS class for every bottom sheet and pass that class to the MatBottomSheet with the panelClass attribute in the configuration object.

this.myBottomSheet.open(MyComponent, {
  panelClass: 'my-ponent-bottom-sheet'
});

In your global styles you define your custom class:

.my-ponent-bottom-sheet {
  min-height: 100vh;
  min-width: 100vw !important;
  margin-top: 80px;
}

And so you can define separate classes for each bottom sheet.

So for something like this, when you want to edit the size, it's easiest to wrap your bottom sheet ponent in a div, and set the min-width on that - rather than trying to override the outer/parent width.

HTML:

     <div class="bottom-sheet-containter">
        //Bottom sheet content
     </div>

CSS:

    .bottom-sheet-containter {
      min-width: 80vw !important;
    }

I had ran into the same problem but this solution worked perfectly for me.

发布评论

评论列表(0)

  1. 暂无评论