如图所示

轮播选项卡_jquery

实现代码

1.html

					<div class="promo_left">
						<div class="content">
							<img src="images/lb01.jpg" alt="">
							<img src="images/lb02.jpg" alt="">
							<img src="images/lb03.jpg" alt="">
							<img src="images/lb04.jpg" alt="">
							<img src="images/lb05.jpg" alt="">
						</div>
						<ul class="nav">
							<li class="title selected">9月12日战斗之</li>
							<li class="title">金铲铲之战上线福利</li>
							<li class="title">五杀摇滚 III</li>
							<li class="title">国服十周年庆典活动</li>
							<li class="title">水墨丹青大礼包</li>
						</ul>
					</div>

2.css

.promo_left{
    width: 100%;
}
.content{
    position: relative;
    width: 100%;
    height: 340px;
    overflow: hidden;
    display: flex;

}
.content img{
    position: absolute;
    display: block;
    max-width: 100%;
    height: 100%;

}

.nav{
    height: 40px;
    overflow: hidden;
    display: flex;
    flex-wrap: nowrap;
}
.nav li{
    list-style: none;
    /* 默认平均分配 */
    flex: 1;
    height: 40px;
    box-sizing: border-box;
    background-color: #e3e2e2;
    font-size: 14px;
    text-align: center;
    line-height: 40px;
    color: #424242;
    letter-spacing: 1px;
    cursor: pointer;
    transition: .33s ease;
}
.selected{
    background-color: #f7f7f6 !important;
    color: #cea861 !important;
    border-bottom: 1px solid #cea861;
}

3.js

//前提:导入jquery。
var timer = null;
// 轮播图更换
function lbt(n) {
    var imgs = $(".content img");
        /*利用jquery框架来获取轮播图*/
    var lis = $(".nav li");
    /*利用jquery框架来获取轮播图文字*/
    for (var i = 0; i < imgs.length; i++) {
        // imgs[i].css({"transform":"translateX(calc("+n+i+"*100%))"});
        var x = i - n;
            /*图片添加动画效果*/
        imgs[i].style.transform = "translateX(calc(" + (i - n) + "*100%))";
        lis[i].removeAttribute("class", "selected");/*文字具体样式*/
    }
    $(".nav li:eq(" + n + ")").addClass("selected");
    /*给文字添加selected样式*/
   
   /*判断  图片顺序*/
    if (n == 4) {
        n = -1;
    }
    m = n + 1;
    timer = setTimeout("lbt(m)", 3000);
}
/* 执行轮播图的函数*/
lbt(0);
window.addEventListener("load",function(){
    $(".nav li").mouseover(function(e) {
        clearTimeout(timer);
        var listls = $(".nav li").length;

        for (var i = 0; i < listls; i++) {

            if (e.target == $(".nav li:eq(" + i + ")")[0]) {
                return lbt(i);
            }
        }
    })
});