html - 在 mat-grid-list 的 mat-grid-tile 组件中垂直堆叠 mat-checkbox

标签 html css angular angular-material

我想要一个包含 2 列的网格列表,并且在这些列中我想要 2 个垂直堆叠的复选框。

我见过 this question 这确实有点工作,但我想知道是否有一个更干净的方法来解决这个问题,因为我必须使用大量的 div 来获得这样就完成了....

我目前的工作方式

<mat-grid-list cols=3 rowHeight="50px">
   <mat-grid-tile class="tile">
       <div>
          <div>
            <mat-checkbox>One</mat-checkbox>
          </div>
          <div>
            <mat-checkbox>Two</mat-checkbox>
          </div>
      </div>
   </mat-grid-tile>
   ...
<mat-grid-list>

最佳答案

向外部 DIV 添加 Flexbox 布局并删除内部 DIV:

<mat-grid-tile>
  <div style="display: flex; flex-direction: column;">
    <mat-checkbox>One</mat-checkbox>
    <mat-checkbox>Two</mat-checkbox>
  </div>
</mat-grid-tile>

关于html - 在 mat-grid-list 的 mat-grid-tile 组件中垂直堆叠 mat-checkbox,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53633464/

相关文章:

html - 准备好的缓存和空缓存有什么区别?

javascript - 以设定的间隔增加和减少 div 的宽度和高度

css - 无法在 safari 中隐藏 youtube iframe?

javascript - 更改为默认样式

javascript - 将修改后的数组发布到 Observable

Angular 2 导入另一个 "sibling"模块会注入(inject)错误的组件

html - 无法设置 rails 4 的标题

javascript - 允许表单发送 POST 请求但阻止页面重新加载 - Javascript

javascript - 如何以 Angular 修复 404(未找到)

javascript - 更改组合框选项 JS 的 "value"