简体   繁体   English

让内容流出<mat-sidenav>而不是为它创建滚动条</mat-sidenav>

[英]Let content flow outside of <mat-sidenav> instead of creating scrollbar for it

Basically I want my dropdown menu to appear on the right side of my dropdownbutton when I click it which already works.基本上我希望我的下拉菜单在我单击它时出现在我的下拉按钮的右侧,这已经有效。 The dropdown menu is to wide however, to fit into my so the sidenav creates a horizontal scrollbar to show all the content.然而,下拉菜单太宽了,以适应我的所以 sidenav 创建了一个水平滚动条来显示所有内容。 I want my dropdown menu to ignore the bounds of the sidenav and flow outside of it.我希望我的下拉菜单忽略 sidenav 的边界并流出它。 Is this possible?这可能吗?

Here is my html这是我的 html


    <mat-sidenav mode="side" #sidenav opened class="dialogCreationMenu">
    <div class="dropdown">
      <button class="dropdownButtonParent" (click)="toggled = !toggled">
          <span>dropdown menu</span>
      </button>
      <div class="dropdown-content" [ngClass]="toggled ? 'dropdown-content-visible' : ''">
        <button class="dropdownButtonChild">
            <span>action1</span>
        </button>
        <button  class="dropdownButtonChild">
            <span>action2</span>
        </button>
      </div>
    </div>
  </mat-sidenav>

The css doesn't really matter, I tried adding overflow: hidden but the content wont flow outside the sidenav. css 并不重要,我尝试添加溢出:隐藏但内容不会流到sidenav之外。 (because I hid it logically) (因为我在逻辑上隐藏了它)

I found a workaround by inspecting the page.我通过检查页面找到了解决方法。 Inside of the mat-sidenav element, there is a mat-drawer-inner-container element with overflow set to auto (resulting in the unwanted scroll behaviour).在 mat-sidenav 元素内部,有一个 mat-drawer-inner-container 元素,其溢出设置为 auto(导致不需要的滚动行为)。 Problem is that I can only override the properties of this class globally (atleast I think so, I'm new with css).问题是我只能全局覆盖这个 class 的属性(至少我认为是这样,我是 css 新手)。 I also found this old issue to it: https://github.com/angular/components/issues/13983 So adding我还发现了这个老问题: https://github.com/angular/components/issues/13983所以添加

        .mat-drawer-inner-container
        {
          overflow:visible !important;
        }
    

(not sure if the.important is necessary to override sucessfully) With this I override the unwanted auto overflow. (不确定是否需要成功覆盖.important)这样我覆盖了不需要的自动溢出。 It should be possible to specify the css class in order to make this change not apply to all mat-drawer-inner-container elements.应该可以指定 css class 以使此更改不适用于所有 mat-drawer-inner-container 元素。 A better solution would be appreciated tho.一个更好的解决方案将不胜感激。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM