纯css实现选项卡

本文介绍了如何仅使用CSS来创建选项卡功能。通过简单的CSS代码,实现了选项卡的切换效果,无需借助JavaScript或其他编程语言。

纯css实现选项卡

效果如下:
在这里插入图片描述

其实用css实现选项卡是非常简单的

css中

.box{width: 302px;height: 302px;border-top: 1px solid gainsboro;text-align: center;margin: 0 auto;}
.box nav{width: 300px;height: 30px;border-bottom: 2px solid gainsboro;}
.box nav a{display: block;width: 100px;flex-shrink: 28px;line-height: 28px;float: left;}
.box .content{width: 300px;height: 270px;overflow: hidden;}
.box .content .cont{width: 300px;height: 270px;line-height: 270px;font-size: 40px;color: white;}
.box .content #one{background: #2E8B57;}
.box .content #two{background: #7CFC00;}
.box .content #three{background: #F4A460;}

body中

<div class="box">
	<nav>
		<a href="#one">按钮1</a>
		<a href="#two">按钮2</a>
		<a href="#three">按钮3</a>
	</nav>
	<div class="content">
		<div id="one" class="cont">内容1</div>
		<div id="two" class="cont">内容2</div>
		<div id="three" class="cont">内容3</div>
	</div>
</div>

就是这么的简单~

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值