left: 40%;
top: 200px;
width: 325px;
text-align: center;
height: 56px;
background-position: 0 -274px;
background-repeat: no-repeat;
line-height: 56px;
color: #9c9c9c;
}
.ggLoading2 {
width: 330px;
height: 56px;
background-position: 213px -330px;
background-repeat: no-repeat;
}
.ggLoading em {
font-weight: bold;
}
.ggs {
width: 200%;
height: 500px;
left: -50%;
top: 0;
position: absolute;
}
.ggBox {
width: 1920px;
height: 500px;
margin: 0 auto;
}
.ggBox a {
display: block;
width: 1920px;
height: 500px;
position: absolute;
z-index: 1;
opacity: 0.1;
}
.ggBox img {
display: block;
width: 1920px;
height: 500px;
}
.ggb {
position: absolute;
width: 100%;
left: 0;
bottom: 0;
height: 40px;
z-index: 4;
background-color: #32342e;
background-repeat: repeat-x;
background-position: 50% -40px;
}
.ggBtns {
width: 960px;
height: 40px;
margin: 0 auto;
border-left: 1px solid #090908;
border-right: 1px solid #6a6a60;
}
.ggBtns a {
float: left;
display: block;
width: 240px;
height: 40px;
text-align: center;
padding-top: 10px;
color: #848380;
font-size: 14px;
line-height: 40px;
background-position: 0 10px;
position: relative;
top: -10px;
outline: none;
background-repeat: no-repeat;
cursor: pointer;
}
.ggBtns a em {
display: block;
width: 210px;
height: 40px;
margin: 0 auto;
overflow: hidden;
}
.ggBtns a:hover {
color: #e7e7e7;
}
.ggBtns a:focus {
outline: none;
}
.ggBtns a.ggOn {
color: #e7e7e7;
background-position: 0 0;
}
.ggb, .ggBtns a {
background-image: url(../images/main.jpg);
}
a.ggOn {
background-image: url(../images/gg.png);
}
JS代码
终于来到重点部分了,这部分的代码不多,一起来看下吧。
$(function () {//文档加载后执行 //定义$con,$box,$btns,$i变量,autoChange自动播放函数,loop定时器。
var $con = $('#gg'), $box = $con.find('#ggBox'), $btns = $con.find('#ggBtns'), i = 0, autoChange = function () {
i += 1;//计数器+1
if (i === 4) { i = 0; }//如果计数器i等4就把i重置为0.
$btns.find('a:eq(' + i + ')').addClass('ggOn').siblings().removeClass('ggOn');
//找到TAB按钮中的第i个a标签,为其加上ggOn的样式,同时移除所有同级的a标签ggOn样式
var curr = $box.find('a:eq(' + i + ')'), prev = curr.siblings();
//定义curr变量,并赋值为$box中当前显示图片的a标签,定义prev变量,赋值为$box中除了当前显示图片的A标签外的所有A标签。










