css - 为 Select 下拉菜单设置 Flex-basis 时不起作用
问题描述
有一个带有 flex-direction: 行的 flex 容器。并且这些单独的列中的每一个都是具有 flex-direction: 列的 flex 容器。
在 flex 行中有一些表单输入,但是当我尝试为 Location 选择一个初始的 flex-basis: 250px 时,它不起作用并且它垂直应用它。
但是,我找不到让它水平应用它的方法。
<div class="row">
<div class="column input-container location">
<label for="location">Location</label>
<select name="location">
<option *ngFor="let location of locations" [value]="location.locationId">
{{location.locationName}}
</option>
</select>
</div>
</div>
//造型
.row {
display: flex;
flex-direction: row;
// flex-wrap: wrap;
}
.column {
display: flex;
flex-direction: column;
}
.location select {
flex-basis: 250px;
}
这是在 stackbliz 中运行的链接,https ://stackblitz.com/edit/angular-vr4cya
解决方案
该flex-basis
属性适用于 flex 容器的主轴。
这意味着 inflex-direction: row
它控制宽度,flex-direction: column
in 控制高度。
如果您flex-direction: column
需要设置弹性项目的宽度,请使用该width
属性。
.additional-assignment[_ngcontent-c0] .location[_ngcontent-c0] select[_ngcontent-c0] {
/* flex-basis: 250px; */
width: 250px; /* new */
更多细节:
推荐阅读
- javascript - 如何从nodejs服务器端的表单标签记录数据?
- android - 当从 Fragment B 到 A 的 popbackstack 时保存 Fragment View(如完成活动)
- c++ - Initialization of a local static variable throught multiple function calls
- angular - 在我的 Angular 项目中,如果没有映射或过滤方法,则无法通过“id”获取数据
- php - Laravel 检查 eloquent 的返回是单个集合还是项目集合
- python - 如何防止硒窗口在会话开始时变为活动窗口?
- excel - 当范围宏中有一个空白单元格时退出 For ¿如何避免这种情况?
- python - 带有更新标签的 Tkinter 加载屏幕
- typescript - 无法读取未定义的属性“VmsUserRoles”
- python - Python中numpy数组、对象到int32的数据类型转换