用css写选项卡

<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
	<style> 


.tabs {
	width:100%;
	/*border:1px solid;*/
	text-align: center;
}
.tabs>div{
	box-sizing:border-box;
	-moz-box-sizing:border-box; 
	-webkit-box-sizing:border-box; 
	width:50%;
	/*border:1px solid red;*/
	float:left;
}


  *{
		margin:0;
		padding:0;
		list-style:none;
		box-sizing:border-box;
	}
	body{
		padding:20px;
	}

	.tabs input[type=radio]{/*隐藏单选框的样式*/
		position:absolute;
		top:-9999px;
		left:-9999px;
	}
	.tabs label{
		margin: 0 auto;
		display:block;
		/*border:1px solid #000;*/
		padding:10px;
		text-align:center;
		/*border-radius:6px 6px 0 0 ;*/
		background:#aaf;
		width:140px;
		position:relative;
		top:4px;
		z-index:3;
		transition:all 0.2s ease-in-out;
 
	}
	.tabs label:hover{
		background:#bbf;
	}
	
	

	.tabs .tab_content{
		width:96%;
		background:#faf;
		height:200px;
		position:absolute;
		top:80px;
		left:0px;
		z-index:2;
		border-top:1px solid #000;
		/*padding:10px;*/
		margin: 0 20px;
		display:none;
	}
	.tabs input[type=radio]:checked + label{
		/*top:0px;*/
		/*padding-top:14px;*/
		border-bottom:1px solid green;
		background:#faf;
	}
	.tabs input[type=radio]:checked ~ div[id^=tab_content]{
		display:block;
	}

</style>
</head>
<body>

	
	<div class="tabs">
		<div>
			<input type="radio" name="tabs" id="tab1" checked/>
			<label for="tab1">选择卡1</label>
			<div class="tab_content" id="tab_content1">
				<p>选项卡1的内容</p>
			</div>
		</div>
		<div>
			<input type="radio" name="tabs" id="tab2"/>
			<label for="tab2">选择卡2</label>
			<div class="tab_content" id="tab_content2">
				<p>选项卡2的内容</p>
			</div>
		</div>
	</div>
<!--</div>-->

</body>
</html>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值