html - formgroup 标签以大写形式显示,但我希望它是 titlecase
问题描述
我有以下角度模板。我注意到,即使在呈现页面时标签是大写的,标签也会转换为大写,我不喜欢它。所以我决定使用 titlecase 管道并用单引号将标签文本括起来。但是,标签仍然是大写的(附上图片以供参考)
我想这应该是直截了当的,但我不知道如何使它工作。有任何想法吗?
<form [formGroup]="updateForm" (ngSubmit)="onSubmit(updateForm.value)">
<div>
<label for="total">
{{'Total' | titlecase}}
</label>
<input id="total" type="text" formControlName="total">
</div>
<div>
<label for="supporters">
{{'Number of supporters' | titlecase}}
</label>
<input id="supporters" type="text" formControlName="supporters">
</div>
<button class="button" type="submit">Save</button>
</form>
解决方案
这似乎是您的 CSS 的问题。
可能,您正在使用<label>
为其设置属性的库或 css 文件text-transform: uppercase;
。
您可以尝试使用自定义 css 规则覆盖它,例如:
HTML
<form [formGroup]="updateForm" (ngSubmit)="onSubmit(updateForm.value)">
<div>
<label class="custom-label-title" for="total">
{{'Total'}}
</label>
<input id="total" type="text" formControlName="total">
</div>
<div>
<label class="custom-label-title" for="supporters">
{{'Number of supporters' }}
</label>
<input id="supporters" type="text" formControlName="supporters">
</div>
<button class="button" type="submit">Save</button>
</form>
CSS
.custom-label-title {
text-transform: capitalize;
}
以防万一它不起作用(仅用于测试目的)添加!important
:
CSS
.custom-label-title {
text-transform: capitalize !important;
}
因为其他 CSS 规则可能具有更大的优先级:
推荐阅读
- java - 创建 .xlsx 文件时出现 Apache POI 运行时错误
- mysql - 使用 GROUP BY 订购时的行值错误
- terraform - Terraform 使用错误版本的提供程序
- image - 为什么 Chrome 会使用 max-age 标头请求已缓存的图像?
- javascript - 使用jquery随机更改多个元素的背景图像
- c# - 当 ASP.Net Core 应用程序发布到 UAT Web 服务器时,最终用户的文件上传失败
- vba - 在组合框中使用向下/向上箭头键选择数据而不更新数据,直到点击选项卡或输入 MS Access
- javascript - 纪元日期时间在未来时离线密码到期
- mysql - MySQL:为什么我的 INSERT 语句在自动递增 id 时会跳过 56 个数字?
- vuex - Vuex ORM 模型依赖循环