使Angular Material Mat-Button-Toggle-Group具有响应式设计

14

我有一个包含 six 个按钮开关的 mat-button-toggle-group。

在桌面上,所有按钮应该在一行中显示。在较小的屏幕上,该组应该分成两行显示按钮,就像这样:enter image description here

这是我的代码(我正在使用 flexbox-grid):

<mat-button-toggle-group class="col-xs-12">
      <mat-button-toggle class="col-xs-4 col-lg-2" value="1">1 Monat</mat-button-toggle>
      <mat-button-toggle class="col-xs-4 col-lg-2" value="3">3 Monate</mat-button-toggle>
      <mat-button-toggle class="col-xs-4 col-lg-2" value="6">6 Monate</mat-button-toggle>
      <mat-button-toggle class="col-xs-4 col-lg-2" value="12">1 Jahr</mat-button-toggle>
      <mat-button-toggle class="col-xs-4 col-lg-2" value="60">5 Jahre</mat-button-toggle>
      <mat-button-toggle class="col-xs-4 col-lg-2" value="120">10 Jahre</mat-button-toggle>
  </mat-button-toggle-group>

在桌面上运行正常,但在移动屏幕尺寸上,只有3个按钮可见(应该在第二行的三个按钮不可见):enter image description here

如何让我的mat-button-toggle-group分成两行?

1个回答

阿里云服务器只需要99元/年,新老用户同享,点击查看详情
29
你必须为toggle-group元素设置flex-wrap属性为wrap:
mat-button-toggle-group {
  flex-wrap: wrap;
}

然后根据您的喜好修整边框即可。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,