200字范文,内容丰富有趣,生活中的好帮手!
200字范文 > css实现tab切换时下划线动画效果

css实现tab切换时下划线动画效果

时间:2020-06-23 13:44:16

相关推荐

css实现tab切换时下划线动画效果

效果图

tab切换下划线效果

<template><view class="tab-box"><view class="tab-item" @click="testTabClick(index)" :class="tabIndex == index?'active':''" v-for="(item,index) in tabList" :key="index">{{item.name}}</view></view></template><script>export default{data() {return {tabIndex:0,tabList:[{name:"电器"},{name:"衣服"},{name:"百货"},{name:"电脑"}]}},methods: {testTabClick(index) {console.log(index)this.tabIndex = index}}}</script><style lang="scss" scoped>.tab-box{display: flex;.tab-item{flex-shrink: 0;padding: 24rpx;position: relative;transition: all 0.2s linear;&::after{transition: all 0.2s linear;transform: translateX(-50%) scaleX(0);content: '';width: 50%;position: absolute;left: 50%;bottom: 20rpx;border-bottom: 6rpx solid red;border-radius: 4rpx;}&.active{&::after{content: '';width: 50%;position: absolute;left: 50%;transform: translateX(-50%) scaleX(1);bottom: 20rpx;border-bottom: 6rpx solid red;}}}}</style>

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。