简体   繁体   English

浮动操作按钮不滚动

[英]Floating Action Button not scrolling

I have a FAB contained in two div tags from parent ( app.component.html ) where one of them uses transform: translate3d. 我有一个FAB包含在父对象( app.component.html )的两个div标记中,其中其中一个使用transform:translate3d。
When scrolling down the page, the FAB is 'stuck' and doesn't scroll. 向下滚动页面时,FAB被“卡住”并且不滚动。

I want this FAB to overlay this entire HTML page (specifically: <div class="page-content"> ) 我希望该FAB覆盖整个HTML页面(具体是: <div class="page-content">
HTML: HTML:

  <div cdk-scrollable="" class="mat-sidenav-content" ng-reflect-ng-style="    " style="margin-left: 0px; margin-right: 0px; transform:     translate3d(0px, 0px, 0px);">
      <div class="page-container">
        <router-outlet></router-outlet>
    <app-carbuilder _nghost-wxw-148="">
            <button style="position: absolute;bottom: 16px;right: 16px;z-index: 5" data-toggle="collapse" data-target="#demo"  aria-expanded="false" aria-controls="demo" md-fab>
            <md-icon>
              directions_car
            </md-icon>
          </button>
        <div class="page-content">
            <p>content</p>
    </div>

(Native image upload didn't work) (本机图像上传无效)
Here's how it looks before & after scroll: 滚动前后的外观如下:

Before 之前
After

Note: 注意:
Similar but not duplicate 相似但不重复
Related 有关
Also Related 也相关

They use CSS transform on .mat-sidenav-content. 他们对.mat-sidenav-content使用CSS转换。
CSS transform creates a new local coordinate system. CSS转换会创建一个新的本地坐标系。

Fix to remove transform: 修复删除转换:

.mat-sidenav-content {
    transform: none !important;
}

Though it resets their intention to force hardware acceleration. 尽管这重置了他们强制硬件加速的意图。

In case anyone is caught up with this problem, there is no solution. 万一有人赶上这个问题,那就没有办法了。 Google's Material theme has addressed the issue here : Google的Material主题已在此处解决了该问题:

FABs inside sidenav Sidenav内的FAB

For a sidenav with a FAB (or other floating element), the recommended approach is to place the FAB outside of the scrollable region and absolutely position it. 对于带有FAB(或其他浮动元素)的卫星导航,建议的方法是将FAB放置在可滚动区域之外,并对其进行绝对定位。

In other words: 换一种说法:
1. Place the Fab in your "app.component.html" (or parent component's HTML) 1.将Fab放置在“ app.component.html”(或父组件的HTML)中
2. use *ngIF to determine if the current route (or component) is active, if true -> display the FAB. 2.使用* ngIF确定当前路由(或组件)是否处于活动状态,如果为true->显示FAB。

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

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