为了账号安全,请及时绑定邮箱和手机立即绑定

减少 Angular Material 标签标签宽度的正确方法?

减少 Angular Material 标签标签宽度的正确方法?

BIG阳 2023-02-24 15:28:09
问题由于/deep/、>>>和已被弃用,在桌面上减少最小宽度为160px::ng-deep的宽度的正确方法是什么?mat-tab-label没有在主要覆盖它styles.css我仍然希望将 Material Tabs 的这种自定义样式限定在父组件范围内。材料规格声明Fixed tabs display all tabs on one screen, with each tab at a fixed width. The width of each tab is determined by dividing the number of tabs by the screen width. They don’t scroll to reveal more tabs; the visible tab set represents the only tabs available.然而,这并不完全正确,在我的例子中,max-width我的父组件设置为320px,这大致允许每个106pxmat-tab-label。编辑 1由于关注点分离, Angular Material 文档提倡的Add the overriding style to your global stylesheet. Scope the selectors so that it only affects the specific elements you need it to.正是我想要避免的
查看完整描述

1 回答

?
交互式爱情

TA贡献1712条经验 获得超3个赞

我最终MatTab在全局中定义了一个自定义样式styles.css:


your-component-selector {

  .mat-tab-label {

    min-width: 25px !important; // In addition to mat-strech-tabs allowing tabs to fill remaining space in parent container

    padding: 5px;

  }

}

your-component-selector将进行范围界定,自定义样式不会在其他组件MatTab实例中流血。

不要忘记使用mat-stretch-tabson<mat-tab-group>来拉伸 Angular Material 选项卡以适应父宽度。


查看完整回答
反对 回复 2023-02-24
  • 1 回答
  • 0 关注
  • 186 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号