<div> <div> <a href="#home">home</a> <a href="#list">list</a> <a href="#news">news</a> <a href="#mine">mine</a> </div> <div> <div>home-page</div> <div>list-page</div> <div>news-page</div> <div>mine-page</div> </div> </div>
css样式设置,即将类名为sh下的div设置为display:none;然后通过div:target{display:block}实现显示选中项
<style type="text/css"> *{margin: 0;padding: 0} .wrap{ width: 400px; height: 600px; border: 1px solid brown; margin: 20px auto; position: relative; } .nav{ width: 100%; height: 30px; } .nav a{ width: 99px; height: 30px; text-align: center; line-height: 30px; border-right: 1px solid brown; border-bottom: 1px solid brown; float: left; text-decoration: none; color:black; } .sh{ width: 400px; height: 569px; position: absolute; left: 0; top:31px; background: #eeeeee; } .sh div{ display: none; text-align: center; } .sh div:target{ display: block; } </style>
到此这篇关于html 实现tab切换的示例代码的文章就介绍到这了,更多相关html tab切换内容请搜索脚本之家以前的文章或继续浏览下面的相关文章,希望大家以后多多支持脚本之家! (编辑:焦作站长网)
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!
|