CSS 模仿谷歌浏览器 tab 标签栏 效果

css 水平很差,还得多练,这里分享给大家谷歌标签栏的模仿效果

效果

普通效果
在这里插入图片描述

压缩到最小时
在这里插入图片描述

鼠标移动效果
在这里插入图片描述

在这里插入图片描述

源码
<template>
	<div class="tabs">
		<div class="tab " media="tab" :class="active" @mouseover="active='active'" @mouseleave="active=''">
			<div><img v-if="icon" class="icon" :src="icon" /></div>
			<div class="title">{{title}}</div>
			<div class="closer">
				<a-icon v-show="active=='active'" type="close" class="closer-icon" />
			</div>
		</div>


	</div>
</template>

<script>
	export default {
		props: {
			title: String,
			icon: String,
		},
		data() {
			return {
				active: '',
			}
		},
		methods: {},
		mounted() {

		},
	}
</script>

<style scoped>
	.tabs {
		
		line-height: 34px;
		height: 34px;
 
	}

	.tab {
		display: flex;
		flex-wrap: nowrap;
		justify-content: start;
 
		min-width: 10px;
		overflow:hidden;
		line-height: 34px;
		height: 34px;
		border: 1px solid rgba(0, 0, 0, 0.1);
		border-bottom: 0px;
		border-radius: 2px;
		background-color: ghostwhite;

		-webkit-app-region: no-drag;

	}
	
	@media screen and (max-width: 500px) {
		.tabs {
			min-width: 5%;
		}
		
		.tabs .title{
			width: 0px;
			min-width: 0px;
		}
		
	}
	
	@media screen and (min-width: 500px) {
		.tabs .tab{
			min-width: 100px;
		}
		.tabs .title{
			
		}
		
	}
	

	/* 悬停样式 */
	.tab:hover {
		background-color: white;
	}

	/* 当前的tab */
	.tab.active {
		background-color: white;
	}



	.icon {


 
		min-width: 20px;
		margin: 0px 6px 6px 6px ;
		width: 20px;
		border-radius: 4px;

	}

	.title {
		/* transform: translate(10px,0); */
		line-height: 34px;
		cursor: default;
		min-width: 0px;
		width: 100%;
		/* 禁止文字复制 */
		-webkit-user-select: none;
		-moz-user-select: none;
		-ms-user-select: none;
		user-select: none;

	}
	
	.closer{
		 display: flex;
		 justify-content: flex-end;
		 background: linear-gradient(to left, ghostwhite, transparent);
	 width: 20px;
	}
 

	.tab.active .closer-icon {
		transform: translateX(-5px);
		margin-top: 5px;
		padding: 3px;
		height: 20px;
		width: 20px;
		justify-content: flex-end;
		border-radius: 50%;
	}

	.tab.active .closer-icon:hover {
 
		background-color: rgba(0, 0, 0, 0.1);
	}
</style>



  • 3
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值