标签和输入框要在一行
时间: 2024-02-17 07:03:32 浏览: 88
css中使input输入框与img(图片)在同一行居中对齐
可以将 `el-form-item` 的样式设置为 `display: flex; justify-content: space-between; align-items: center;`,同时将 `label` 标签的宽度设置为固定值,如 `width: 100px;`。这样,每个表单项的标签和输入框就会在同一行,并且标签的宽度也会固定。完整代码如下:
```html
<div style="display: flex; justify-content: center; align-items: center; width: 700px; margin: 0 auto;">
<el-form :model="user" status-icon :rules="rules" ref="ruleForm" class="demo-ruleForm" style="width: 100%;">
<el-form-item label="密码" prop="username" style="display: flex; justify-content: space-between; align-items: center; width: 100%;">
<span style="width: 100px;">密码:</span>
<el-input type="password" v-model="user.pass" autocomplete="off" width="250px"></el-input>
</el-form-item>
<el-form-item label="确认密码" prop="password" style="display: flex; justify-content: space-between; align-items: center; width: 100%;">
<span style="width: 100px;">确认密码:</span>
<el-input type="password" v-model="user.checkPass" autocomplete="off"></el-input>
</el-form-item>
<el-form-item label="身份" prop="rank" style="display: flex; justify-content: space-between; align-items: center; width: 100%;">
<span style="width: 100px;">身份:</span>
<el-select v-model="user.rank" placeholder="请选择">
<el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value">
</el-option>
</el-select>
</el-form-item>
<el-form-item style="display: flex; justify-content: center; align-items: center; width: 100%;">
<el-button type="primary" @click="submitForm">提交</el-button>
<el-button @click="resetForm">重置</el-button>
</el-form-item>
</el-form>
</div>
```
阅读全文