1、利用a标签target,点击之后对应id的div会有 :target 伪类。
<style type="text/css">
*{
margin: 0;
padding: 0;
text-decoration: none;
}
.tab{
width: 300px;
height: 300px;
margin: 30px auto;
overflow: hidden;
}
.nav{
height: 30px
}
.content{
height: 270px;
overflow: hidden;
}
.cont{
height: 270px;
}
#the1{
background: green;
}
#the2{
background: blue;
}
</style>
<div class="tab">
<div class="nav">
<a href="#the1">ONE</a>
<a href="#the2">TWO</a>
</div>
<div class="content">
<div id="the1" class="cont">第一张</div>
<div id="the2" class="cont">第二张</div>
</div>
</div>
2、利用radio按钮和:checked选择器
网友评论