简体   繁体   English

Angular Mat-dialog 显示了两个滚动条,如何删除第二个?

[英]Angular Mat-dialog is displaying two scrollbars, how can I remove the second?

I'm trying to build an angular aplication that needs a dialog component on the click of a button, and the problem is that when the Dialog opens it displays two scrollbars (as you can see in the picture), one for the content and another for the whole dialog.我正在尝试构建一个 angular 应用程序,它需要一个单击按钮的对话框组件,问题是当对话框打开时它显示两个滚动条(如图所示),一个用于内容,另一个对于整个对话。 I've tried a few solutions to it, like adding 'overflow:hidden' to the css file or 'padding:0' as some solution say on the forums, but it haven't worked yet.我已经尝试了一些解决方案,比如在 css 文件中添加“溢出:隐藏”,或者像论坛上的一些解决方案所说的那样添加“填充:0”,但它还没有奏效。 Can anyone help me?谁能帮我? (My intent is to keep only the inner scrollbar.) (我的意图是只保留内部滚动条。)

Image of the problem: [1]: https://i.stack.imgur.com/oU9hD.png问题图片:[1]: https://i.stack.imgur.com/oU9hD.png

PS: this is a angular example dialog, which the source code can be found at: https://material.angular.io/components/dialog/examples in the section "Dialog with header, scrollable content and actions". PS:这是一个angular的示例对话框,源代码可以在: https://material.angular.io/components/dialog/examples中的“Dialog with header, scrollable content and actions”部分找到。

Please let me know if I need to provide any other info about the problem如果我需要提供有关该问题的任何其他信息,请告诉我

The outer container of the dialog overflow property set to 'auto'.对话框溢出属性的外部容器设置为“自动”。 Try to target the specific class of the outer container and set the height and overflow property to 'initial', which will remove the fixed height and overflow property and allow the container to adjust to the size of its content.尝试针对外部容器的特定 class 并将高度和溢出属性设置为“初始”,这将删除固定高度和溢出属性并允许容器调整其内容的大小。

.mat-dialog-container {
  height: initial;
  overflow: initial;
}

Another thing you can try is to add overflow: auto to the inner container of the dialog您可以尝试的另一件事是将 overflow: auto 添加到对话框的内部容器

.mat-dialog-content {
  overflow: auto;
}

i've solved the problem here just now... It happened that the mat-dialog-content had overflow:auto and the dialog class itself had a 24px padding, so i've discovered that a could define a new class to the dialog (using panelClass as a property on the dialog.open() fucntion) inside the function that creates it, so I made it and defined it as 0px.我刚刚在这里解决了这个问题...碰巧 mat-dialog-content 溢出了:auto 并且对话框 class 本身有一个 24px 的填充,所以我发现 a 可以为对话框定义一个新的 class (使用 panelClass 作为 dialog.open() 函数的属性)在创建它的 function 中,所以我做了它并将其定义为 0px。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 显示带有通用组件的 Mat-dialog - Displaying Mat-dialog with Common Component Angular 8 从全屏打印垫对话框中去除打印介质中的奇怪线条 - Angular 8 remove weird lines from print media from printing mat-dialog in full screen size Angular:如何在 mat-dialog 上的 mat-select 中返回所选项目的所有数据,同时保留所选默认值的代码 - Angular: How do I return all data for selected item in mat-select on mat-dialog whilst keeping code for selected default value 如何在打印 mat-dialog 时隐藏 @media 打印的 Angular 9 背景组件? - How to hide Angular 9 background component for @media print while printing mat-dialog? 如何为 angular 材料垫选择使用“.cdk-overlay-pane”自定义或应用另一个 class 垫子对话框 - How to customize or apply another class with ".cdk-overlay-pane" for angular material mat-select | mat-dialog Angular 4 材质 - mat-button 样式未应用于 mat-dialog 组件 - Angular 4 Material - mat-button style not being applied in mat-dialog component Mat-Dialog 未在浏览器的全屏模式下显示 - Mat-Dialog is not showing in fullscreen mode of browser 如何使用jquery从iframe中删除滚动条? - How can I remove scrollbars from an iframe using jquery? 根据对象在 Mat-Dialog 中显示不同的信息? - Display different information in Mat-Dialog depending on object? 如何从div中删除滚动条的1秒外观 - How to remove a 1-second appearance of scrollbars from a div
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM