前面的话
导航条Tab在页面中非常常见,本文说详细介绍CSS实现导航条Tab的三种方法
布局

根据上图所示,先规定几个定义,上图的模块整体叫做导航,由导航标题和导航内容组成。要实现上图所示的布局效果,有两种布局方法:语义布局和视觉布局
【语义布局】
从语义布局的角度来看,每一个导航标题和其对应的导航内容应该是一个整体
<style>
body,p{margin: 0;}
h2{margin: 0;font-size:100%;}
ul{margin: 0;padding: 0;list-style: none;}
a{text-decoration: none;color:inherit;}
.box{width: 572px;border: 1px solid #999;overflow: hidden;}
.nav{margin-left: -1px;font: 14px "微软雅黑";overflow: hidden;background-color: #f1f1f1;}
.navI{float: left;width: 33.333%;box-sizing: border-box;}
.navI-tit{line-height: 40px;text-align: center;cursor: pointer;border-left: 1px solid #cecece;border-bottom: 1px solid #cecece;}
.navI-txt{width: 572px;height:200px;text-indent:2em;line-height: 2;background:#fff;}
.ml1{margin-left: -100%;}
.ml2{margin-left: -200%;}
.navI_active{position:relative;z-index:1;}
</style><div class="box">
<ul class="nav">
<li class="navI navI_active">
<h2 class="navI-tit">课程</h2>
<p class="navI-txt">课程内容</p>
</li>
<li class="navI">
<h2 class="navI-tit">学习计划</h2>
<p class="navI-txt ml1">学习计划内容</p>
</li>
<li class="navI">
<h2 class="navI-tit">技能图谱</h2>
<p class="navI-txt ml2">技能图谱内容</p>
</li>
</ul>
</div>
【视觉布局】
从视觉布局的角度来看,所有导航标题为一组,所有导航内容为一组
<style>
body,p{margin: 0;}
ul{margin: 0;padding: 0;list-style: none;}
a{text-decoration: none;color: inherit;}
.box{width:572px;border:1px solid #999;font:14px "微软雅黑";overflow:hidden;}
.nav-tit{margin-left: -1px;height: 40px;line-height: 40px;text-align: center;background-color: #f1f1f1;overflow: hidden;}
.nav-titI{box-sizing: border-box;float: left;width: 33.333%;border-left: 1px solid #cecece;border-bottom: 1px solid #cecece;cursor: pointer;}
.nav-txt{height: 200px;text-indent: 2em; line-height: 2;}
.nav-txtI{height: 200px;}
</style><div class="box">
<nav class="nav-tit">
<a class="nav-titI">课程</a>
<a class="nav-titI">学习计划</a>










