首先看效果图
如图所示,标签在浏览器窗口居中,但是下面的内容依然是默认从左到右,不会受到tab样式的影响文章来源地址https://www.toymoban.com/news/detail-840968.html
<template>
<div>
<div style="display: flex; justify-content: center; align-items: center;">
<el-tabs v-model="activeName" class="demo-tabs no-content" @tab-click="handleClick">
<el-tab-pane label="文本" name="first">
<!-- <TextCode />-->
</el-tab-pane>
<el-tab-pane label="网址" name="second"></el-tab-pane>
<el-tab-pane label="文件" name="third"></el-tab-pane>
<el-tab-pane label="图片" name="fourth"></el-tab-pane>
<el-tab-pane label="音视频" name="five"></el-tab-pane>
</el-tabs>
</div>
<div style="background-color: #f6f8f7;">
<TextCode v-if="activeName === 'second'"/>
</div>
</div>
</template>
<script lang="ts" setup>
import { ref } from 'vue'
import type { TabsPaneContext } from 'element-plus'
import TextCode from "./code/textCode.vue";
const activeName = ref('first')
const handleClick = (tab: TabsPaneContext, event: Event) => {
console.log(tab, event)
}
</script>
<style>
.demo-tabs > .el-tabs__content {
padding: 32px;
color: #6b778c;
font-size: 32px;
font-weight: 600;
background-color: #f6f8f7;
}
.no-content .el-tabs__content {
display: none;
}
</style>
文章来源:https://www.toymoban.com/news/detail-840968.html
到了这里,关于更改el-tabs默认样式,实现tab标签居中显示,标签对应内容使用另一个div显示的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!