Element UI之el-tabs的样式修改字体颜色、下划线、选中/未选中

目录

默认样式

修改默认字体颜色:

修改鼠标悬浮/选中字体颜色:

去掉长分割线并修改下划线颜色

完整代码


默认样式

注意事项:一定要在 <style scoped>不然修改的样式不会覆盖生效

修改默认字体颜色:

css 复制代码
::v-deep .el-tabs__item {
    color:green;
    opacity: 0.5;
}

修改鼠标悬浮/选中字体颜色:

css 复制代码
::v-deep .el-tabs__item.is-active {
  color: red;//选中
  opacity: 1;
}

::v-deep .el-tabs__item:hover {
  color: red;//悬浮
  cursor: pointer;
  opacity: 1;
}

去掉长分割线并修改下划线颜色

css 复制代码
/*去下划线 */
::v-deep .el-tabs__nav-wrap::after {
  position: static !important;
}

/* 下划线颜色 */
::v-deep .el-tabs__active-bar {
  background-color: red;
}

完整代码

javascript 复制代码
<template>
    <el-tabs v-model="activeName" @tab-click="handleClick">
        <el-tab-pane label="User" name="first">User</el-tab-pane>
        <el-tab-pane label="Config" name="second">Config</el-tab-pane>
        <el-tab-pane label="Role" name="third">Role</el-tab-pane>
        <el-tab-pane label="Task" name="fourth">Task</el-tab-pane>
    </el-tabs>
</template>
<script lang="ts" setup>
import { ref } from 'vue'
import type { TabsPaneContext } from 'element-plus'
import { ElTabs, ElTabPane } from "element-plus";

const activeName = ref('first')

const handleClick = (tab: TabsPaneContext, event: Event) => {
    console.log(tab, event)
}
</script>
<style scoped>
.demo-tabs>.el-tabs__content {
    padding: 32px;
    color: #6b778c;
    font-size: 32px;
    font-weight: 600;
}

::v-deep .el-tabs__item {
    color: green;
    opacity: 0.5;
}

/**选中 */
::v-deep .el-tabs__item.is-active {
    color: red;
    opacity: 1;
}

/**悬浮 */
::v-deep .el-tabs__item:hover {
    color: red;
    cursor: pointer;
    opacity: 1;
}


/*去下划线 */
::v-deep .el-tabs__nav-wrap::after {
    position: static !important;
}

/* 下划线颜色 */
::v-deep .el-tabs__active-bar {
    background-color: red;
}
</style>
  
相关推荐
想吃火锅10051 分钟前
【leetcode】20.有效的括号js
linux·javascript·leetcode
问心无愧05132 分钟前
ctfshow web入门114
android·前端·笔记
aaaa954726653 分钟前
终端与IDE形态Vibe Coding实测:主流AI编程工具迁移与迭代对比
javascript·react.js·ecmascript
晓得迷路了7 分钟前
栗子前端技术周刊第 133 期 - Angular v22、React 编译器 Rust 版、pnpm 11.5...
前端·javascript·css
一个被程序员耽误的厨师9 分钟前
02-架构篇-前端怎么反客为主把AI编排权拿回到自己手里
前端·人工智能·架构
云浪13 分钟前
别再让用户干等了:用 Express + SSE 实现《红楼梦》AI 问答实时输出
javascript·后端·node.js
羊羊小栈16 分钟前
基于混合检索RAG的食品生产质量问答系统(BGE_BM25_大语言模型)
前端·人工智能·语言模型·自然语言处理·毕业设计·大作业
烤代码的吐司君17 分钟前
Redis 服务配置与使用
前端·bootstrap·html
之歆20 分钟前
Ajax 基础技术深度解析:XHR 从入门到跨域
前端·ajax·okhttp
怕浪猫21 分钟前
Electron 开发实战(十四):实战项目|从零搭建轻量化桌面代码编辑器
前端·electron·node.js