简体   繁体   English

Angular 带有固定选项卡 Header 和固定 Div In Content 的材料选项卡

[英]Angular Material Tabs with Fixed Tab Header and Fixed Div In Content

Trying to accomplish this:试图做到这一点:

在此处输入图像描述

And although I have had some success with getting the tab header row fixed, I just can't get the div with the buttons to remain fixed as well (I think because it is part of the tab content and not the tab header)虽然我在固定选项卡 header 行方面取得了一些成功,但我无法让按钮也保持固定(我认为因为它是选项卡内容的一部分,而不是选项卡标题)

Any thoughts / solutions?有什么想法/解决方案吗? I'm starting to think that the angular material tabs will not work for my UI.我开始认为 angular 材质选项卡不适用于我的 UI。 Is it possible to build the rendered html for the tabs manually and move the toolbar button div into the tab header container?是否可以手动为选项卡构建渲染的 html 并将工具栏按钮 div 移动到选项卡 header 容器中?

https://stackblitz.com/angular/mkdpjkxlemv https://stackblitz.com/angular/mkdpjkxlemv

Wrap the content below the fixed header to a div将固定的header下面的内容包裹到一个div

<div class="header">
    <button mat-raised-button>Button 1</button>
    <button mat-raised-button>Button 2</button>
</div>
<div class="content">
     Content
</div>

Give it a fixed height as you desire then set overflow to auto根据需要给它一个固定的高度,然后将overflow设置为auto

.content{
  height: 40vh;
  overflow: auto;
  padding: 1em;
}

Here is a fully working example .这是一个完整的工作示例 Hope this helps.希望这可以帮助。

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

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