十年网站开发经验 + 多家企业客户 + 靠谱的建站团队
量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决
html代码

创新互联坚持“要么做到,要么别承诺”的工作理念,服务领域包括:成都做网站、成都网站制作、企业官网、英文网站、手机端网站、网站推广等服务,满足客户于互联网时代的萨迦网站设计、移动媒体设计的需求,帮助企业找到有效的互联网解决方案。努力成为您成熟可靠的网络建设合作伙伴!
实现简单的tab框
css代码
* {
margin: 0;
padding: 0px;
}
ul {
width: 300px;
margin: 10px auto;
}
ul li {
list-style: none;
}
.main li {
text-align: center;
float: left;
padding: 5px;
margin-left: 10px;
width: 80px;
cursor: pointer;
background-color: #f3f2e7;
}
.main .style1 {
width: 50px;
font-weight: bold;
background-color: #f3f2e7;
border: 1px solid #837979;
border-bottom: 0;
z-index: 100;
position: relative;
}
.sublevel {
width: 260px;
height: 80px;
padding: 19px;
background-color: #f3f2e7;
clear: left;
border: 1px solid #837979;
position:relative;
top: -1px;
}
.sublevel li{
display: none;
}
.sublevel .style1{
display: block;
}
jquery代码
$(function () {
//页面打开时 呈现的效果
$(".sublevel li:eq(0)").show();
//each遍历输出
$(".main li").each(function(index) {
//click 点击
$(this).click(function() {
//addClass()增加当前样式 removeClass()移除除当前点击之外的同级样式
$(this).addClass("main style1").siblings().removeClass("style1");
$(".sublevel li:eq("+index+")").show().siblings().hide();
})
})
})
以上这篇使用jQuery实现简单的tab框实例就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持创新互联。