html - 如何将文本与输入字段的中间对齐?
问题描述
我正在尝试将我的文本对齐span tag
到input field
. 但是当我"text-align": center
在我的css中使用它时,它不起作用。
当我把它改成span tag
我paragraph tag
变input field
大的时候。
编码:
<div class="nxui-form-group">
<label for="external-realisation">
<img src="assets/images/purchase_order.svg" class="nxui-icon-small nxui-icon-align-bottom">
{{ 'i18n.all-damage-reports.label.external-realisation' | translate }}
</label>
<div *ngIf="!isExternal">
{{ 'i18n.all-damage-reports.label.without-order' | translate }}
</div>
<div *ngIf="isExternal" class="nxui-label-plus-field">
<span class="nxui-non-breakable-label">{{ 'i18n.all-damage-reports.label.with-order' | translate }} </span>
<input [nxuiPlaceholder]="'i18n.all-damage-reports.label.external-realisation' | translate"
[title]="'i18n.all-damage-reports.label.external-realisation' | translate"
class="nxui-form-control"
formControlName="company"
id="external-realisation"
pInputText
>
</div>
</div>
当我添加以下内容时,它看起来像这样paragraph tag
:
回答我的问题:
.nxui-label-plus-field {
display: flex;
align-items: center;
}
.nxui-non-breakable-label {
white-space:nowrap ;
}
高度赞赏的投入。
谢谢
解决方案
HTML:
<div *ngIf="isExternal" class="nxui-label-plus-field">
<span class="nxui-non-breakable-label">{{ 'i18n.all-damage-reports.label.with-order' | translate }} </span>
<input [nxuiPlaceholder]="'i18n.all-damage-reports.label.external-realisation' | translate"
[title]="'i18n.all-damage-reports.label.external-realisation' | translate"
class="nxui-form-control"
formControlName="company"
id="external-realisation"
pInputText
>
</div>
CSS:
<style>
.nxui-label-plus-field {
display: flex;
align-items: center;
}
</style>
推荐阅读
- excel - 数字格式在 VBA 中无法正常工作
- node.js - 生产服务器上 docker 环境中的 Node.js 内存泄漏
- c# - 如何实例化一个类?
- c++ - 有人可以解释 3D 形状中的 Z 值是多少吗?
- firebase - 如何在颤振飞镖中每 20 秒显示一次插页式广告
- ibm-cloud - IBM Cloud:无法访问 Ambari 控制台
- python - Python中时间序列的真实样本外预测
- javascript - ReferenceError:foundItems 未定义
- java - 使用 JAVA 获取 WebElement 在屏幕上的位置
- python-3.x - 使用 Python 3.7 云函数并行写入 Firestore