bootstrap-4 - 如何在 Angular 材料 8 中连续平均分割两个 mat-form-fields?
问题描述
如何在 Angular 材料 8 中连续平均分割两个 mat-form-fields?
<div class="row">
<div class="col-md-6 offset-md-3 col-xs-12" style="width: 50%">
<mat-form-field>
<input matInput placeholder="Mode" readonly>
</mat-form-field>
</div>
<div class="col-md-6 offset-md-3 col-xs-12" style="width: 50%">
<mat-form-field>
<input matInput placeholder="Type" readonly>
</mat-form-field>
</div>
</div>
解决方案
col-md-6
不使用offset-md-3
(更多关于offset)。style="width: 50%"
是不必要的。另请注意,这仅适用于 ≥768px(源)的视口,并且col-xs-*
在 bootstrap 4 中是col-*
.
说明:由于每个引导行有 12 个单元格,而您的 div 需要 9 个单元格(偏移量为 6 + 3),因此第二个 div 移动到下一行。删除offset-md-3
后,两个 div 都在同一行中。
请参阅以下演示:(
我必须添加col-6 offset-3
,col-6
因为代码段输出对于 来说太小了col-md-*
)
.red{
background: red;
}
.yellow{
background: yellow;
}
.row {
height: 100px;
width: 400px;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<div class="col-12">
Current situation:
<div class="row border">
<div class="col-md-6 offset-md-3 col-6 offset-3 red"></div>
<div class="col-md-6 offset-md-3 col-6 offset-3 yellow"></div>
</div>
Sub-divs in one row:
<div class="row border">
<div class="col-md-6 col-6 red"></div>
<div class="col-md-6 col-6 yellow"></div>
</div>
Space between:
<div class="row border">
<div class="col-5 red"></div>
<div class="col-5 offset-2 yellow"></div>
</div>
Space around:
<div class="row border justify-content-around">
<div class="col-5 red"></div>
<div class="col-5 yellow"></div>
</div>
</div>
推荐阅读
- android - vs代码中的扩展不加载
- full-text-search - 电报组过滤
- ffmpeg - 使用 ffmpeg 为 Cloud Speech-to-Text 录制流音频
- php - Laravel Passport API 上传多张图片
- types - 使用流相交两种类型的正确方法
- php - PHP嵌套'if'代码故障排除检查收件人和发件人消息/电子邮件转发
- html - 如果页面没有带有分页的行,则隐藏表头(飞碟)
- java - 内容类型 'application/json;charset=UTF-8'
- javascript - 我们可以在 webGL 中使用 HTML 元素制作平面几何吗?
- kendo-ui - 剑道电子表格浏览器兼容性