Angular Material 2 : How to put a fab button on top of the md-table at the bottom right corner?

别来无恙 提交于 2019-12-04 02:46:52

The code below meets the requirements but is pretty dirty to be called straight forward solution.

What i did while playing with position : fixed , margin , z-index and bottom was that i made a div just below the md-table (on the level of paginator).

<div style="z-index:5; position : fixed;display : flex; 
align-self : flex-end;bottom : 10%; margin-bottom : 68px;">

<a md-mini-fab routerLink="." style="margin-right : 14px;" (click) = 
"tShowAdu()"><md-icon>add</md-icon></a>
<a md-mini-fab routerLink="/main/create" style="margin-right : 14px;"><md-icon>add</md-icon></a>

</div>

Note : Would update the answer or Post a new one if a better solution is found.

You can wrap the md-table and md-mini-fab inside a div. Then, you can use position: absolute to float to the button on top of the md-table and use right and top css properties to adjust the position of the button.

html:

<div class="example-container mat-elevation-z8">
  <a md-mini-fab class="custom-button"><md-icon>check</md-icon></a>
  <md-table #table [dataSource]="dataSource" style="margin-top: 50px">
    ...
    ...
    ...
  </md-table>
</div>

css:

.custom-button{
  position: absolute;
  right: 30px;
  top: 15px;
}

Plunker demo

Note: Since you mentioned "the table of content would run under it" I added margin-top: 50px to the table to position it below the button.

Andrés Martín D'Oria

Use class="md-fab md-fab-bottom-right"

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