如何通过css调整el-select 当为多选框时的默认高度
// 想通过样式进行调整,并没有生效
.el-input .el-input__inner,
.el-select .el-select__input{
font-size: 12px;
height: 32px;
line-height: 32px;
}
好像是个内联样式,感觉应该时渲染时动态加载的
如果height: 32px !important;
,那么当多选时,又不会自动撑开了,如下图所示:
如何通过css调整el-select 当为多选框时的默认高度
// 想通过样式进行调整,并没有生效
.el-input .el-input__inner,
.el-select .el-select__input{
font-size: 12px;
height: 32px;
line-height: 32px;
}
好像是个内联样式,感觉应该时渲染时动态加载的
如果height: 32px !important;
,那么当多选时,又不会自动撑开了,如下图所示:
最简单的写法,当然得手动刷新页面
<style>
.el-input input {
height: 38px
}
</style>
原因:
mounted() {
// el-select会设置一个初始化高度
this.initialInputHeight = input.getBoundingClientRect().height || sizeMap[this.selectSize];
}
methods: {
resetInputHeight() {
if (this.collapseTags && !this.filterable) return;
this.$nextTick(() => {
if (!this.$refs.reference) return;
let inputChildNodes = this.$refs.reference.$el.childNodes;
let input = [].filter.call(inputChildNodes, item => item.tagName === 'INPUT')[0];
const tags = this.$refs.tags;
// this.initialInputHeight优先级最高
const sizeInMap = this.initialInputHeight || 40;
input.style.height = this.selected.length === 0
? sizeInMap + 'px'
: Math.max(
tags ? (tags.clientHeight + (tags.clientHeight > sizeInMap ? 6 : 0)) : 0,
sizeInMap
) + 'px';
if (this.visible && this.emptyText !== false) {
this.broadcast('ElSelectDropdown', 'updatePopper');
}
});
},
}
只有一种情况才需要按照@Griffin23的说法去修改el-tag
的高度,即el-tag
比初始的initialInputHeight
的高度还高
10 回答11.2k 阅读
5 回答4.8k 阅读✓ 已解决
4 回答3.1k 阅读✓ 已解决
2 回答2.8k 阅读✓ 已解决
3 回答4.9k 阅读✓ 已解决
2 回答4.8k 阅读✓ 已解决
4 回答4.4k 阅读✓ 已解决
设置
el-select size="small"
。size可选medium/small/mini。medium - 36,small - 32,mini - 28也可以参考 @看见了 的答案,直接修改input高度
以下是相关源码: