css - Css 对齐材料设计单选按钮
问题描述
我正在使用垫单选按钮。我预期的用户界面应该是这样的,
使用以下代码,
<mat-radio-group name="employeeType" formControlName="employeeType" fxLayout="row">
<mat-radio-button *ngFor="let type of employeeTypes" (change)="showFieldByEmployeeType($event)"
[value]="type.name">
{{ type.name}}</mat-radio-button>
</mat-radio-group>
但我得到,
是否有任何有用的 CSS 让它看起来像预期的那样?
解决方案
模板
<mat-radio-group class="radio-parent" name="employeeType"
formControlName="employeeType"
fxLayout="row">
<mat-radio-button class="radio-item" *ngFor="let type of employeeTypes"
(change)="showFieldByEmployeeType($event)"
[value]="type.name">
{{ type.name}}</mat-radio-button>
</mat-radio-group>
CSS
.radio-parent{
display: flex;
justify-content: space-between;
align-items: center;
flex-wrap: wrap;
}
.radio-item{
flex: 1 0 21%;
margin: 5px;
}
它不会生成完全相同的结构,您必须使用值来获得所需的结构。
推荐阅读
- ebay-api - 如何使用 eBay Browse API 仅通过一台服务器搜索产品
- ios - iOS - removeDeliveredNotifications、removeAllDeliveredNotifications 用于关键警报
- r - Geom_ribbon 有两个不同位置的组
- sql-server - 将第二行作为列移动并保持第一行完整 sql
- python - import psutil ImportError: 没有名为 psutil 的模块
- python - Matplotlib 动画 - 间隔 arg 没有在视频中给出间隔
- python - 将鼠标悬停在 x 轴上具有日期时间的图形的绘图上时显示标签
- laravel - 每当 LARAVEL 中发生任何更新时发送通知
- node.js - 将 API 中的 EC2 容器中的图像发送到前端应用程序
- keycloak - 如何在访问令牌中显示客户端角色属性