本文摘自PHP中文网,作者coldplay.xixi,侵删。
Css实现tab选项卡切换的方法:利用target的特性,可以实现纯css的tab效果切换,代码为【#tab1:target,#tab2:target,#tab3:target{z-index:1;}】。
本教程操作环境:windows7系统、css3版,DELL G3电脑。
Css实现tab选项卡切换的方法:
CSS3伪类target
利用target的特性,可以实现纯css的tab效果切换
示例代码如下
代码如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | <style type= "text/css" >
.tabmenu{
position:absolute;
top:-28px;
left:144px;
margin:0px;
}
.tabmenu li{
display:inline-block;
}
.tabmenu li a{
display:block;
padding:5px 10px;
margin:0 10px 0 0;
border:1px solid #91a7b4;
border-radius:5px 5px 0 0;
background-color:#e3f1f8;
color:#333;
text-decoration: none;
font-size:16px;
}
.tablist{
position:relative;
top:200px;
margin:0 auto;
width:600px;
min-height:200px;
}
.tab_content{
position:absolute;
width:600px;
height:170px;
padding:15px;
border:1px solid #91a7b4;
border-radius:10px;
box-shadow:0 2px 3px rgba(0,0,0,0,1);
font-size:16px;
line-height:16px;
color:#666;
background-color:#fff;
}
#tab1:target,#tab2:target,#tab3:target{
z-index:1;
}
</style>
<div class = "tablist" >
<ul class = "tabmenu" >
<li><a href= "#tab1" >tab1</a></li>
<li><a href= "#tab2" >tab2</a></li>
<li><a href= "#tab3" >tab3</a></li>
</ul>
<div id= "tab1" class = "tab_content" >tab1</div>
<div id= "tab2" class = "tab_content" >tab2</div>
<div id= "tab3" class = "tab_content" >tab3</div>
</div>
|
最关键的代码
阅读剩余部分
相关阅读 >>
css中px是什么意思
css的伪类选择器
html如何让链接不变色
css如何设置边框
css border-right-style属性怎么用
css具备什么特点
css reset是什么意思?
css超出宽度怎么显示省略号
css border-style属性怎么用
css怎么去除滚动条
更多相关阅读请进入《css》频道 >>
人民邮电出版社
本书对 Vue.js 3 技术细节的分析非常可靠,对于需要深入理解 Vue.js 3 的用户会有很大的帮助。——尤雨溪,Vue.js作者
转载请注明出处:木庄网络博客 » Css如何实现tab选项卡切换