fix(styles): 修复必填星号首行对齐问题

- 调整 `.is-required .el-form-item__label` 采用 `align-items: normal` 实现星号首行对齐
- 覆盖 Element Plus 固定高度 `height: 32px` 为 `height: auto` 以支持内容自适应高度
- 保持 `align-self: center` 使单行 label 与输入框垂直居中,折行时星号贴首行
- 修改星号 `::before` 的高度为 `auto` 并继承行高,保证首行基线一致
- 修复多行 label 下星号因 flex 居中导致位置偏移的问题
- 兼容 label 多种位置(右、左、顶)及多行折行场景,影响 project-apply 等表单页
This commit is contained in:
2026-09-09 11:11:39 +08:00
parent 06f6950434
commit be2888d428
2 changed files with 29 additions and 17 deletions
+20 -17
View File
@@ -708,9 +708,9 @@
.avue-crud .el-table__body-wrapper tr.el-table__row:nth-child(even) td.el-table__cell,
.avue-crud .el-table__body-wrapper tr.el-table__row:nth-child(even) td.el-table-fixed-column--left,
.avue-crud
.el-table__body-wrapper
tr.el-table__row:nth-child(even)
td.el-table-fixed-column--right {
.el-table__body-wrapper
tr.el-table__row:nth-child(even)
td.el-table-fixed-column--right {
background-color: #fafafa;
}
@@ -1045,31 +1045,34 @@
}
.el-form-item--default .el-form-item__label {
//line-height: 14px;
line-height: 14px;
}
// ============ 必填星号 * 与 label 首行齐平(全局) ============
// label 为 inline-flex,星号 ::before 与文字是两个独立 flex 子项;
// 多行折行 label 若 align-items: center,星号会被垂直居中到第二行位置。
// align-items: flex-start 让星号与文字首行齐平;
// align-self: center 让 label 整体不随表单行(32px)拉伸,单行 label 仍与输入框垂直居中,视觉不变
.el-form-item--label-right .el-form-item__label,
.el-form-item--label-left .el-form-item__label,
.el-form-item--label-top .el-form-item__label {
.el-form-item--label-right .el-form-item__label {
align-items: center;
}
// ============ 必填星号 * 与 label 首行齐平(仅换行时生效) ============
// label 为 inline-flex,星号 ::before 与文字是两个独立 flex 子项
// align-items: normal= stretch):单行时星号盒子 = 一行高,位置不变;
// 折行后星号盒子被拉伸到 label 全高,但其内部按 line-height 从顶部排布 → 星号停在第一行。
// height: auto 覆盖 Element Plus 写死的 32px,让 label 收缩到内容高;
// align-self: center 再让收缩后的 label 在表单行内垂直居中(单行与输入框对齐)。
.is-required .el-form-item__label {
height: auto;
align-self: center;
align-items: flex-start;
align-items: normal;
}
.el-form-item--default {
margin-bottom: 14px;
}
// 辅助:星号跟随 label 行高,保证与首行文字基线一致(单行/多行通用)。
// 注:真正的首行对齐由上方 .el-form-item__label 的 align-items: flex-start 完成;
// 客商档案(customer-archive)的 label 为 auto 高度 + padding 下沉方案,scoped 特异性更高会覆盖本规则。
// 配套:星号必须保持「高度 auto + 继承行高」,stretch 才会按首行排布;
// 写死 height 或 line-height 与 height 相等时效果会退化成居中。
// 注:客商档案(customer-archive)的 label 为 auto 高度 + padding 下沉方案,scoped 特异性更高会覆盖本规则。
.el-form-item.is-required .el-form-item__label::before {
display: inline-block;
height: auto;
line-height: inherit;
margin-right: 4px;
margin-top: 2px !important;
}
//.el-form-item {
// margin-bottom: 15px !important;