el-input文字居中
时间: 2023-11-08 22:04:35 浏览: 103
可以通过在 el-input 上设置 text-align:center; 的样式来实现文字居中。
示例代码:
```html
<template>
<div>
<el-input v-model="inputValue" style="text-align:center;"></el-input>
</div>
</template>
<script>
export default {
data () {
return {
inputValue: ''
}
}
}
</script>
```
相关问题
el-input 输入居中
要使el-input输入居中,可以使用以下方法:
1. 使用内联样式:在el-input标签上添加style属性,并设置text-align为center。
```html
<el-input style="text-align: center;"></el-input>
```
2. 使用CSS类选择器:在样式表中为el-input添加一个类选择器,并设置text-align为center。
```html
<style>
.center-input .el-input__inner {
text-align: center;
}
</style>
<el-input class="center-input"></el-input>
```
3. 使用父元素的样式:如果el-input是el-card的子元素,可以在el-card的样式中设置text-align为center。
```html
<el-card style="text-align: center;">
<el-input></el-input>
</el-card>
```
el-input设置居中显示
要将el-input的内容居中显示,可以使用以下方法:
1. 使用CSS样式设置el-input的内容居中显示。在你的代码中,可以通过给el-input的父元素添加自定义的CSS样式来实现内容居中显示。例如,给el-card的子元素el-col添加一个类名为center的样式,并在样式中设置文本居中对齐。
```html
<el-card>
<el-col :span="10" class="center">
<el-input></el-input>
</el-col>
</el-card>
<style>
.center {
text-align: center;
}
</style>
```
2. 使用内联样式设置el-input的内容居中显示。如果你不想使用CSS样式文件,也可以直接在el-col元素上使用内联样式来设置文本居中对齐。
```html
<el-card>
<el-col :span="10" style="text-align: center;">
<el-input></el-input>
</el-col>
</el-card>
```
这两种方法都可以将el-input的内容居中显示。