html - 选项卡中包含的卡片内容上的角度材质滚动条
问题描述
请帮助解决我在设置角形材料标签时遇到的问题。
请参阅: https ://stackblitz.com/edit/angular-6-material-tab-problem?file= app/tab.component.html [编辑:在进行我在我的回答]
第一个选项卡接近我想要的方式:
- 当 mat-card-content 中的内容超出选项卡中的可见空间时,溢出-y 滚动条可用。
- mat-card 或 mat-tab 上没有滚动条应该能够适当地调整大小。
- 例如,在调整窗口大小时,mat-tab-group 的高度可能会变高——如果需要,mat-card-content 也应该变高并且可以滚动。
但是,当 mat-card-content 中的内容长度不超过选项卡的高度时,就会出现问题。
例如,虽然样式相同,但第二个选项卡不正确。mat-card 的红色矩形应填充 mat-tab 的高度。最右边还有一个不需要的滚动条。
这是模板:
<mat-tab-group>
<mat-tab label="Properties">
<mat-card class="scrollable-content">
<mat-card-header>
<mat-card-title>Card Data</mat-card-title>
</mat-card-header>
<mat-card-content>
My Content for this card...<br>
0 Lots and lots of content.<br>
1 Lots and lots of content.<br>
2 Lots and lots of content.<br>
3 Lots and lots of content.<br>
4 Lots and lots of content.<br>
5 Lots and lots of content.<br>
6 Lots and lots of content.<br>
7 Lots and lots of content.<br>
8 Lots and lots of content.<br>
9 Lots and lots of content.<br>
10 Lots and lots of content.<br>
11 Lots and lots of content.<br>
12 Lots and lots of content.<br>
13 Lots and lots of content.<br>
14 Lots and lots of content.<br>
15 Lots and lots of content.<br>
16 Lots and lots of content.<br>
17 Lots and lots of content.<br>
18 Lots and lots of content.<br>
19 Lots and lots of content.<br>
20 Lots and lots of content.<br>
21 Lots and lots of content.<br>
22 Lots and lots of content.<br>
23 Lots and lots of content.<br>
</mat-card-content>
</mat-card>
</mat-tab>
<mat-tab label="2nd Tab">
<mat-card class="scrollable-content">
<mat-card-header>
<mat-card-title>Other Stuff</mat-card-title>
</mat-card-header>
<mat-card-content>
2nd Tab
</mat-card-content>
</mat-card>
</mat-tab>
</mat-tab-group>
这是CSS:
.mat-card.scrollable-content{
overflow: hidden;
display: flex;
flex-direction: column;
}
.mat-card.scrollable-content mat-card-content {
overflow-y: auto;
}
.mat-card.scrollable-content mat-card-title {
display: block;
}
.mat-tab-group {
height: 400px;
border: 2px solid #00F;
}
.mat-card-content {
border: 2px solid #0F0
}
.mat-card-title {
font-weight: bold;
font-size: 1.25em !important;
}
.mat-card {
border: 2px solid #F00;
height: 85%;
}
.mat-tab-label{
font-weight: bold;
font-size: 1.25em;
}
解决方案
在意识到模板中使用的材料设计元素被预处理到其他 css 类之后,我能够解决这个问题。
我通过将以下内容添加到 css 中使其工作:
.mat-tab-body-content {
overflow: hidden !important;
}
.mat-tab-body-wrapper {
height: 100% !important;
}
推荐阅读
- r - 如何将 direct.label() 与简单(两个变量)ggplot2 图表一起使用
- node.js - 每次更改分支时如何避免 npm install ?
- google-apps-script - 是否仍然可以发布 Gmail 插件?
- mysql - 如何从列的逗号分隔值中查找子部分并在 mysql 中插入新行?
- javascript - 如何在 onchange 事件中使用 php、ajax 上传图片
- javascript - ReactJS Ref:获取输入元素值的未定义错误
- r - 无法计算两个日期之间的差异
- node.js - 如何在节点 js 中使用 async 和 await 函数提取数据?
- mysql - 如何将一个表与另一个只有 1 个公共值的表连接起来
- mobile - 控制台打印以在 c 中显示信号电平