【Jquery滑动选项卡】

滑动选项卡

css样式

<style>
        .btns input {
            width: 100px;
            height: 40px;
            background-color: grey;
            border: 0;
        }

        .cons {
            width: 500px;
            height: 300px;
            overflow: hidden;
            position: relative;
        }

        .slides {
            width: 1500px;
            height: 300px;
            /*把slide加长*/
            position: absolute;
        }

        .cons>.slides>.litteBox {
            width: 500px;
            height: 300px;
            background-color: gold;
            text-align: center;
            line-height: 300px;
            font-size: 30px;
            float: left;
        }
    </style>

静态

<body>
    <div class="btns">
        <input type="button" value="01" style="background-color: gold" />
        <input type="button" value="02" />
        <input type="button" value="03" />
    </div>
    <div class="cons">
        <div class="slides">
            <div class="litteBox">选项卡1的内 容</div>
            <div class="litteBox">选项卡2的内容</div>
            <div class="litteBox">选项卡3的内容</div>
        </div>
    </div>
</body>

js

<script>
    $('div>input').click(function () {
        $('div>input').eq($(this).index()).css('background', 'gold').siblings().css('background', '')
        $('.slides').animate({ left: '-500'*$(this).index()+'px'}, 1000)
    })
</script>
以下是一个基于jQuery的垂直滑动选项卡的示例代码: ```html <!DOCTYPE html> <html> <head> <title>垂直滑动选项卡</title> <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.5.1/jquery.min.js"></script> <style type="text/css"> .tab { width: 200px; height: 300px; border: 1px solid #ccc; overflow: hidden; position: relative; } .tab ul { margin: 0; padding: 0; list-style: none; position: absolute; top: 0; left: 0; width: 100%; height: 100%; } .tab ul li { height: 50px; line-height: 50px; padding-left: 20px; background-color: #f5f5f5; border-bottom: 1px solid #ccc; cursor: pointer; } .tab ul li.active { background-color: #fff; font-weight: bold; } .tab .content { position: absolute; top: 0; left: 200px; width: 400px; height: 300px; background-color: #fff; border: 1px solid #ccc; padding: 20px; } </style> <script type="text/javascript"> $(function() { $('.tab ul li').click(function() { var index = $(this).index(); $(this).addClass('active').siblings().removeClass('active'); $('.tab .content').eq(index).show().siblings('.content').hide(); }); }); </script> </head> <body> <div class="tab"> <ul> <li class="active">选项卡1</li> <li>选项卡2</li> <li>选项卡3</li> <li>选项卡4</li> <li>选项卡5</li> </ul> <div class="content"> <div>内容1</div> <div style="display: none;">内容2</div> <div style="display: none;">内容3</div> <div style="display: none;">内容4</div> <div style="display: none;">内容5</div> </div> </div> </body> </html> ``` 该示例代码实现了一个垂直滑动选项卡,当鼠标点击选项卡标签时,对应的内容会显示出来。你可以根据自己的需求修改样式和内容。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值