tab页面切换的功能我们已经和大家分享过很多,本文我们主要和大家绍css实现tab页切换实例代码,需要的朋友可以参考下,希望能帮助到大家。
1.hover
移入其父元素.navI时,触发鼠标的hover态,给父元素添加样式为position:relative;z-index:1;。从而提升了层级z-index。在其子元素导航内容的层级比拼中,“子凭父贵”,父元素层级高的,其导航内容在重叠状态中显示在最上面
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;}/*重点代码*/.navI:hover{position:relative;z-index:1;}.navI:hover .navI-tit{background:#fff;border-bottom:none;}
登录后复制
课程
课程内容
学习计划
学习计划内容
技能图谱
技能图谱内容
2.锚点
点击导航标题时,触发target伪类,改变对应的导航内容的层级z-index,从而使当前导航内容在三个导航内容中胜出,在最上层显示;与此同时,改变当前导航标题的样式
立即学习“前端免费学习笔记(深入)”;
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;position:relative;}.navI-tit{position:absolute;top:0;left:0;right:0;box-sizing: border-box;line-height: 40px;height: 40px;text-align: center;cursor: pointer;border-left: 1px solid #cecece;border-bottom: 1px solid #cecece;}.navI-txt{width: 572px;height:200px;margin-top: 40px;text-indent:2em;line-height: 2;background:#fff;}.ml1{margin-left: -100%;}.ml2{margin-left: -200%;}.navI_active{z-index:1;}/*重点代码*/.navI-txt:target{position:relative;z-index:1;}.navI-txt:target ~ .navI-tit{background:#fff;border-bottom:none;}
登录后复制
课程内容
课程
学习计划内容
学习计划
技能图谱内容
技能图谱
3.radio
点击导航标题时,触发checked伪类,改变对应的导航内容的层级z-index,从而使当前导航内容在三个导航内容中胜出,在最上层显示;与此同时,改变当前导航标题的样式
body,p{margin: 0;}ul{margin: 0;padding: 0;list-style: none;}a{text-decoration: none;color: inherit;}input{margin: 0;padding: 0;border:none;}.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;}.nav-txtI{height: 200px;display:block;width: 100%;text-indent: 2em; line-height: 2;}/*重点内容*/.nav-txt{overflow: hidden;}.nav-titI:hover{background-color: #fff;border-bottom:none;}
登录后复制
相关推荐:
微信小程序Tab页切换更新数据详细介绍
微信小程序Tab页切换更新数据详细介绍
微信小程序Tab页切换更新数据详细介绍
以上就是CSS如何实现Tab页切换的代码分享的详细内容,更多请关注【创想鸟】其它相关文章!
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至253000106@qq.com举报,一经查实,本站将立刻删除。
发布者:PHP中文网,转转请注明出处:https://www.chuangxiangniao.com/p/2900297.html