点击放大图片、滚动缩放图片(无插件,自己写的)

来源:互联网 发布:玩minecraft学编程 编辑:程序博客网 时间:2024/05/16 13:43

<script src="~/js/jquery.js"></script>//

<style type="text/css">

    #block {
        width: 0px;
        height: 100%;
    }
     #cts img {
        vertical-align: middle;
     }

</style>

<body>


<div style="position:absolute;display:none;top:0;left:0;width:100%;background-color:#676767;" id="cts">
    <div style="position:absolute;top:0;right:0;">
        <img src="~/Image/Practice/close_1.png" class="imgRoll" id="CloseBig"/>
    </div>
    <div style="margin:0 auto;text-align:center;vertical-align:middle;" id="imgVer">
        <img src="/images/1.jpg" style="width:800px;height:auto;" onmousewheel="return bigimg(this)"/>
        <img src="" id="block"/>//利用空图片实现上下左右居中
    </div>
</div>

<script type="text/javascript">

function bigimg(i) {
    var zoom = parseInt(i.style.zoom, 10) || 100;
    zoom += event.wheelDelta / 12;
    if (zoom > 0)
        i.style.zoom = zoom + '%';
    return false;
}


$(function(){

$("#smallIMG").click(function () {
        $("#cts").css("display", "block");
    })
    $("#CloseBig").click(function () {
        $("#cts").css("display", "none");
    })


    $("#cts").css("height", document.body.clientHeight + "px");
    $("#imgVer").css("height", document.body.clientHeight + "px");

})

</script>

</body>

0 0
原创粉丝点击