jquery左侧分类导航菜单和图片轮播滚动布局代码添加更多

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>慕课</title>
    <link rel="stylesheet" href="css/reset.css">
    <link rel="stylesheet" href="css/idangerous.swiper.css">
    <link rel="stylesheet" href="lib/layui/css/layui.css">
    <link rel="stylesheet" href="css/index.css">
    <style>
        .hide {
    display: none;
}

.header-top {
    width: 100%;
    height: 30px;
    background-color: #2F3030;
}

.header-safe {
    max-width: 1920px;
    min-width: 1200px;
    height: 30px;
    background-color: #2F3030;
    margin: 0 auto;
}

.header-content {
    width: 1200px;
    height: 30px;
    background-color: #2F3030;
    margin: 0 auto;
}

.header-content .info {
    color: #FFFFFF;
    font-size: 14px;
    line-height: 30px;
}

.header-content .login-reg,
.header-content .login-reg a {
    color: #FFFFFF;
    font-size: 14px;
    line-height: 30px;
}

.header-bottom {
    width: 100%;
    height: 135px;
}

.header-safety {
    max-width: 1920px;
    min-width: 1200px;
    height: 135px;
    margin: 0 auto;
}

.header-logo {
    width: 1200px;
    height: 135px;
    margin: 0 auto;
}

.search {
    margin-top: 55px;
}

.search .select {
    line-height: 30px;
    margin-right: 20px;
}

.search select {
    border: 0;
    color: #2F3030;
    font-size: 16px;
    width: auto;
    padding: 0 2%;
    margin: 0;
    text-align: center;
    text-align-last: center;
}

.sousuo {
    position: relative;
    width: 300px;
    height: 30px;
    border: 1px solid #CACACA;
    border-radius: 5px;
}

.sousuo input {
    width: 252px;
    height: 30px;
    border: 0;
    border-radius: 5px;
    margin-left: 22px;
}

.sousuo .search-btn {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 26px;
    height: 26px;
    border-radius: 5px;
    background-color: #EC6D3A;
}

.banner {
    width: 100%;
    height: 375px;
}

.banner-safe {
    position: relative;
    max-width: 1920px;
    min-width: 1200px;
    height: 100%;
    margin: 0 auto;
}

.banner-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 300px;
    z-index: -99;
    background-repeat: no-repeat;
    background-size: cover;
    -webkit-filter: blur(6px);
    -moz-filter: blur(6px);
    -o-filter: blur(6px);
    -ms-filter: blur(6px);
    filter: blur(6px);
}

.baner-content {
    position: relative;
    width: 1200px;
    height: 100%;
    margin: 0 auto;
}

.baner-content .swiper-container {
    position: relative;
    width: 100%;
    height: 100%;
}

.baner-content .swiper-container .swiper-slide img {
    width: 100%;
    height: 100%;
}

.baner-content .pagination {
    position: absolute;
    bottom: 19px;
    left: 48%;
}

.baner-content .swiper-pagination-switch {
    display: inline-block;
    width: 32px;
    height: 3px;
    margin-right: 14px;
    cursor: pointer;
    background-color: #fff;
}

.baner-content .swiper-active-switch {
    background: #EC6D3A;
}

.baner-content .tab {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 99;
    background-color: rgba(0, 0, 0, .4);
    color: #FFFFFF;
}

.baner-content .tab span {
    font-size: 20px;
    margin-left: 20px;
    margin-right: 20px;
}

.baner-content .tab li {
    cursor: pointer;
    height: 74px;
    line-height: 74px;
    padding: 0 20px;
    border-bottom: 1px solid rgba(255, 255, 255, .5);
    border-right: 1px solid rgba(255, 255, 255, .5);
}

.baner-content .tab li:last-child {
    border-bottom: 0;
}

.baner-content .tab li a {
    font-size: 16px;
    color: #fff;
    margin-right: 20px;
    border-bottom: 1px solid transparent;
}

.baner-content .tab li a:hover {
    border-bottom: 1px solid #fff;
}

.baner-content .tab .list {
    width: 300px;
    padding: 20px;
    top: 0;
    line-height: 30px;
}

.baner-content .tab .list a {
    font-size: 16px;
    color: #fff;
    border-bottom: 1px solid transparent;
    margin-right: 14px;
}

.baner-content .tab .list a:hover {
    border-bottom: 1px solid #fff;
}

.baner-content .tab .more {
    cursor: pointer;
}
    </style>
</head>

<body>
    <div class="banner">
        <div class="banner-safe">
            <div class="banner-bg">
            </div>
            <div class="baner-content">
                <div class="swiper-container">
                    <div class="swiper-wrapper">
                        <div class="swiper-slide">
                            <img src="images/index1.jpg" alt="">
                        </div>
                        <div class="swiper-slide">
                            <img src="images/index2.jpg" alt="">
                        </div>
                        <div class="swiper-slide">
                            <img src="images/index3.jpg" alt="">
                        </div>
                    </div>
                    <div class="pagination"></div>
                </div>
                <div class="tab clearfix">
                    <ul class="f-left">
                        <li><span>国学</span><a href="">摄影</a><a href="">唱歌</a><i class="layui-icon" style="font-size: 16px; color: #fff;">&#xe602;</i> </li>
                        <li><span>国学</span><a href="">摄影</a><a href="">唱歌</a><i class="layui-icon" style="font-size: 16px; color: #fff;">&#xe602;</i> </li>
                        <li><span>国学</span><a href="">摄影</a><a href="">唱歌</a><i class="layui-icon" style="font-size: 16px; color: #fff;">&#xe602;</i> </li>
                        <li><span>国学</span><a href="">摄影</a><a href="">唱歌</a><i class="layui-icon" style="font-size: 16px; color: #fff;">&#xe602;</i> </li>
                        <li><span>国学2</span><a href="">摄影</a><a href="">唱歌</a><i class="layui-icon" style="font-size: 16px; color: #fff;">&#xe602;</i> </li>
                        <div class="more">
                            <div class="gengduo hide" style="height:74px;line-height:74px;font-size:20px;text-align:center;border-right:1px solid rgba(255, 255, 255, .5);">更多<i class="layui-icon" style="font-size: 16px; color: #fff;">&#xe61a;</i>
                            </div>
                            <ul class="hide">
                                <li><span>国学</span><a href="">摄影</a><a href="">唱歌</a><i class="layui-icon" style="font-size: 16px; color: #fff;">&#xe602;</i> </li>
                                <li><span>国学</span><a href="">摄影</a><a href="">唱歌</a><i class="layui-icon" style="font-size: 16px; color: #fff;">&#xe602;</i> </li>
                            </ul>
                        </div>
                    </ul>
                    <div class="list hide f-left">
                        <a href="">国学1</a>
                        <a href="">国学2</a>
                        <a href="">国学3</a>
                        <a href="">国学4</a>
                        <a href="">国学5</a>
                        <a href="">国学6</a>
                        <a href="">国学7</a>
                        <a href="">国学8</a>
                        <a href="">国学9</a>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script src="lib/jquery-3.2.1.min.js"></script>
    <script src="lib/idangerous.swiper.min.js"></script>
    <script src="lib/layui/layui.all.js"></script>
    <script src="js/index.js"></script>
    <script>
        var bg1 = $('.baner-content .swiper-container .swiper-slide').eq(0).children('img').attr('src');
    $('.banner-bg').css("background-image", "url(" + bg1 + ")");
    var mySwiper = new Swiper('.baner-content .swiper-container', {
        pagination: '.baner-content .pagination',
        paginationClickable: true,
        moveStartThreshold: 100,
        autoplay: 1500,
        loop: true,
        onSlideChangeEnd: function(swiper) {
            bg();
        }
    })

    function bg() {
        var bg = $('.baner-content .swiper-slide-active').children('img').attr('src');
        $('.banner-bg').css("background-image", "url(" + bg + ")");
    }
    var height = $('.tab').height();
    var height2 = 75 * $('.tab .more li').length;
    $('.baner-content .tab .list').css('height', height - 41 + 'px');
    $('.tab').mouseover(function(event) {
        $('.baner-content .tab .list').show();
    });
    if ($('.tab li').length > 5) {
        $('.tab .gengduo').show();
        $('.tab>ul li:nth-child(5)').remove();
    }
    $('.tab .more').mouseenter(function(event) {
        if ($('#remove').length === 0) {
            $('.tab .more li:first-child').before('<li id="remove"><span>国学2</span><a href="">摄影</a><a href="">唱歌</a><i class="layui-icon" style="font-size: 16px; color: #fff;">&#xe602;</i> </li>');
        }
        $('.tab .more>ul').show();
        $('.tab .gengduo').hide();
        // $('.baner-content .tab .list').css('left', width2 + 'px');
        $('.baner-content .tab .list').css('height', height + height2 - 41 + 'px');
    });
    $('.tab').mouseleave(function(event) {
        $('.baner-content .tab .list').hide();
        $('.tab .gengduo').show();
        $('.tab .more>ul').hide();
        // $('.baner-content .tab .list').css('left', width + 'px');
        $('.baner-content .tab .list').css('height', height - 41 + 'px');
    });
    </style>
</body>

</html>

 

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值