jq 动态相册

本文介绍如何利用jQuery库实现一个动态相册功能,包括图片轮播、过渡效果和导航控制。通过实例代码解析,帮助读者掌握动态相册的实现技巧。
摘要由CSDN通过智能技术生成
<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
    <style>
        body {
            background-color: black;
            overflow: hidden;
        }

        .divbg {
            position: relative;
            width: 500px;
            height: 300px;
            margin: 0 auto;
            margin-top: 200px;
        }

        .imglist {
            position: absolute;
            height: 300px;
            box-shadow: 0px 0px 20px white;
            transition: transform 0.5s linear;
        }

        .jiantou {
            position: absolute;
            z-index: 989999;
            width: 50px;
            bottom: 0;
            left: 41%;
        }
    </style>
</head>
<body>
<div class="divbg">
    <img class="imglist" src="./img/0.jpg" alt=""/>
    <img class="imglist" src="./img/1.jpg" alt=""/>
    <img class="imglist" src="./img/2.jpg" alt=""/>
    <img class="imglist" src="./img/3.jpg" alt=""/>
    <img class="imglist" src="./img/0.jpg" alt=""/>
    <img class="imglist" src="./img/1.jpg" alt=""/>
    <img class="imglist" src="./img/2.jpg" alt=""/>
    <img class="imglist" src="./img/3.jpg" alt=""/>
    <img class="jiantou" src="./111.png" alt=""/>
</div>
<script src="jquery-3.0.0.js"></script>
<script>
    $(function () {
        var widthnum = 500;
        $(".imglist").each(function (index) {
            widthnum -= 20;
            $(this).css({
                "zIndex": -index,
                "width": widthnum + "px",
                "marginLeft": index * 10 + "px",
                "transform": "translatez(" + -index * 30 + "px) translatey(" + -index * 15 + "px)"
            });
        });
        $(".jiantou").click(function () {
            showanminate(300);
        });
        $(".imglist").each(function (index) {
            $(this).click(function () {
                if (index % 2 == 0) {
                    $(this).css({
                        "transform": $(this).css("transform") + "translatex(300px)"
                    });
                }
                else {
                    $(this).css({
                        "transform": $(this).css("transform") + "translatex(-300px)"
                    });
                }
            })
        })
        function showanminate(time) {
            $(".imglist:first").animate({"top": "500px", "opacity": "0"}, time, function () {
                $(".imglist").each(function (index) {
                    $(this).css({
                        "zIndex": parseInt($(this).css("zIndex")) + 1,
                        "width": parseInt($(this).css("width")) + 20 + "px",
                        "marginLeft": parseInt($(this).css("marginLeft")) - 10 + "px",
                        "transform": "translatez(" + (-index * 30 + 30) + "px) translatey(" + (-index * 15 + 15) + "px)"
                    });
                })
                $(this).css({
                    "top": "0",
                    "opacity": "1",
                    "zIndex": "-7",
                    "width": "340px",
                    "marginLeft": "70px",
                    "transform": "translateZ(-210px) translateY(-105px)"
                })
                $(this).appendTo($(".divbg"));
            })
        }
    });
</script>
</body>
</html>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值