修改el-select默认样式

在开发过程中,我们一般遇到特殊的UI效果图,不得不修改<el-select>默认样式了。

修改el-select框样式

html 复制代码
<template>
       <el-select
         v-model="yearValue"
         class="select_box"
         multiple
         placeholder="请选择年份支持多选"
         :teleported="false"
         >
            <el-option
              v-for="item in yearOptions"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            />
        </el-select>
</template>
css 复制代码
.select_box {
    width: 170px;

    // 默认placeholder
    :deep(.el-input__inner::placeholder) {
        color: #ccc;
    }

    // 默认框状态样式更改
    :deep(.el-input__wrapper) {
        background-color: #1d333700 !important;
        box-shadow: 0 0 0 1px #3fa6f4 inset !important;
        --el-select-focus-border-color: #3fa6f4 !important;
        --el-select-hover-border-color: #3fa6f4 !important;
    }

    // 修改下拉框样式-点击框focus
    :deep(.is-focus .el-input__wrapper) {
        box-shadow: 0 0 0 1px #3fa6f4 inset !important;
        --el-select-focus-border-color: #3fa6f4 !important;
        --el-select-hover-border-color: #3fa6f4 !important;
    }

    :deep(.el-select__caret) {
        color: #3fa6f4 !important; // 清除按钮
    }

    :deep(.el-input__inner) {
        color: #3fa6f4 !important; // 选中字体色
    }

    :deep(.el-select-dropdown__empty) {
        background-color: #072258;
        color: #ddd !important;

    }

    :deep(.el-select-dropdown__wrap) {
        color: #fff;
        background-color: #072258;
        color: #ddd !important;
    }

    :deep(.el-select-dropdown__item) {
        color: #fff !important;
    }

    :deep(.el-select-dropdown__item.hover) {
        background-color: rgb(22, 81, 244) !important;
        color: #ddd !important;
    }

    :deep(.el-select-dropdown__item.selected) {
        background-color: rgb(22, 81, 244) !important;
        color: #ddd !important;
    }

    :deep(.el-select-tags-wrapper.has-prefix>span) {
        background-color: rgb(22, 81, 244) !important;
        color: #ddd !important;
    }
}

// 下拉框-展开样式
.el-select-dropdown__item.selected {
    // background-color: #83e818!important; // 选中
}

.el-select-dropdown__item.hover {
    background-color: #121f1b !important; // hover
}

:deep .el-dropdown-menu__item:not(.is-disabled) {
    // color: #182F23!important; // disabled
}

.el-select-dropdown__item {
    color: #3fa6f4 !important; // 下拉项颜色
}

:deep .el-popper {
    background-color: #121f1b !important; // 展开下拉背景
    border: 1px solid #3fa6f4 !important; // 展开下拉边框
}

:deep .el-popper .el-popper__arrow::before {
    border-top: 1px solid #3fa6f4 !important; // 箭头按钮边框
    background-color: #121f1b !important; // 箭头按钮背景色
}

这里需要注意一点,<el-select>修改下拉框的样式需要加上**:teleported="false"**详细看element plus官网文档

相关推荐
Hyyy5 小时前
普通前端续命周报——第1周
前端·javascript
赏金术士7 小时前
第六章:UI组件与Material3主题
android·ui·kotlin·compose
GISer_Jing8 小时前
Three.JS渲染架构解读
java·javascript·架构
时寒的笔记8 小时前
day13~14核心案例某采招网
开发语言·javascript·ecmascript
智商不够_熬夜来凑9 小时前
【Picker】单选多选
前端·javascript·vue.js
测试员周周9 小时前
【Appium 系列】第18节-重试与容错 — 移动端测试的稳定性保障
人工智能·python·功能测试·ui·单元测试·appium·测试用例
米饭不加菜9 小时前
Typora 原生流程图语法完全指南(Flowchart.js)
前端·javascript·流程图
scan7249 小时前
langgraphy条件边
前端·javascript·html
用户9385156350710 小时前
《JS 对象知识地图:10 个小节,从字面量到原型链全覆盖》
javascript