How does element ui modify the color of a single label

I made a form with element ui, in which there are many label, who just want to change the color of one of the label to red, but several methods don"t work. I have tried to add a class to label, but it doesn"t work. Do you know which god?

Css
Apr.05,2021

I tried it. It's OK to write like this. Let's give you a reference.

style

<style>
    .redItem .el-form-item__label{
        color: red;
    }
</style>

template

<el-form label-width="80px" :model="formLabelAlign">
                <el-form-item label="">
                    <el-input v-model="formLabelAlign.name"></el-input>
                </el-form-item>
                <el-form-item label="" class="redItem">
                    <el-input v-model="formLabelAlign.region"></el-input>
                </el-form-item>
                <el-form-item label="">
                    <el-input v-model="formLabelAlign.type"></el-input>
                </el-form-item>
</el-form>

js

data() {
     return {
           formLabelAlign: {
                 name: '',
                 region: '',
                 type: ''
           }
     };
},

result:

clipboard.png


possible reasons:
1, the priority of css is not enough and is overridden, and you need to add enough selector nesting (or use important), to ensure that the priority of css is higher than element ui's css
2). The use of < style scoped > < / style > scoped attribute in the vue component limits the style scope of the component and cannot work on other components

.
Menu